#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,r,count=0;
clrscr();
printf("Enter a number");
scanf("%d",&n);
for(i=2;i<n;i++)
{
r=n%i;
if(r==0)
{
count++;
break;
}
}
if(count==0 && n!=1)
{
printf("It is a Prime number");
}
else
{
printf("It is not a prime number");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i;
clrscr();
printf("\nEnter any number:");
scanf("%d",&num);
i=2;
while(i<=num-1)
{
if(num%i==0)
{
printf("\nNumber is not prime.");
break;
}
i++;
}
if((i==num)(num==1))
printf("\nNumber is prime.");
getch();
}
#include
#include
void main()
{
int j,n;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
j=2;
while(j<=n)
{
if(n%j==0)
break;
j++;
}
if(j==n)
printf("%d is Prime",n);
else
printf("%d is Not Prime",n);
getch();
}
#include<stdio.h>
// returns true if num is non-zero and is equal to
// the sum of all its proper positive divisors.
bool is_perfect (unsigned num)
{
unsigned div=0, sum=0;
while(++div<num)
if(num%div==0)
sum+=div;
return num && num==sum;
}
void main()
{
unsigned n;
printf("Enter a number: ");
scanf("%d",&n);
if(is_perfect(n))
printf("The number %d is perfect\n", n);
else
printf("The number %d is not perfect\n", n);
}
#include<stdio.h>
bool is_prime (const unsigned int num) {
if (num<2) return false;
if (!(num%2)) return num==2;
unsigned int max_factor = sqrt (num) + 1;
unsigned int factor;
for (factor=3; factor<max_factor; factor+=2)
if (!(num%factor)) return false;
return true;
}
int main (void) {
printf ("Input a number: ");
unsigned int num;
scanf("%d", num);
if (num<0) num*=-1; /* ensure num is positive */
if (is_prime (num))
printf ("The number is prime\n");
else
printf ("The number is composite\n");
return 0;
}
create a program that iterates until it finds a perfect number, then store that perfect number into an array. Continue iterating until you find three more. Then, you have an array of four perfect numbers.
int i; for (i=2; i<=30; i+=2) printf ("%d\n", i);
There is no limit to the number of functions you can have in a program. The only practical limit is dependant upon the amount of memory you have available in order to load the compiled program, whether it has 4 functions or 4 trillion functions. If the program makes use of dynamic libraries, then the amount of available memory reduces accordingly.
To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.
Write a shell program to test whether the given number is a perfect number or not.#include#includevoid main(){int n,s=0,i;clrscr()printf("s=");scanf("%d",&n);for(i=0;i
class perfect{public static void main(int n) // input as parameter{int a=0;for(int i=1;i
The program is here guys.......... //Finding whether the given number is perfect or not //Starts here #include<stdio.h> void main() { int i=1,temp=0,number; scanf("%d",&number); while(i<=number/2){ if(number%i==0) temp+=i; i++; } if(temp==number) printf("Its a perfect number"); else printf("Its not a perfect number"); } //ends here
8086 assembly language program to check wether given number is perfect or not
It is unknown whether an odd perfect number actually exists. If an odd perfect number exists it will be extremely large, that is in excess of 10300.
write a c++program by using if statement to read a number and check whether it is positive or negative
No, it isn't. In fact, it is not known whether are odd perfect numbers exist. The first perfect numbers are 6, 28, 496, and 8128.
No. The only perfect numbers less than 100 are 6 and 28. All known perfect numbers are even - it is unknown whether there are odd perfect numbers.
You can tell whether a number is a square number by looking at the last digit. A perfect square number ends with either 1, 4, 5, 6, 9 or 00.
create a program that iterates until it finds a perfect number, then store that perfect number into an array. Continue iterating until you find three more. Then, you have an array of four perfect numbers.
If the sum of all a number's factors (factors that are smaller than the number itself) is equal to the number itself, the number is said to be "perfect". For example, the factors of 6 (excluding 6 itself) are 1, 2, and 3; and the sum of these numbers is exactly 6. The smallest perfect numbers are 6, 28, 496, 8128. It isn't known whether the set of perfect numbers is finite or infinite. Also, it isn't known whether there are any odd perfect number; all known perfect numbers are even.
Yes. The only known almost perfect numbers are the powers of 2. 32 = 2^5 is an almost perfect number. It has not yet been proved whether {x: x = 2^n for n in N} = {x: x is an almost perfect number}.
Yes, Skyward is Emirates frequent flyer program.