answersLogoWhite

0

#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();

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

How do you write a C program to find out perfect numbers from 1 and 50?

To find perfect numbers between 1 and 50 in a C program, you can iterate through each number in that range and check if it is equal to the sum of its proper divisors. A perfect number is defined as a number that is equal to the sum of its positive divisors, excluding itself. Here's a basic outline of the program: #include &lt;stdio.h&gt; int main() { for (int num = 1; num &lt;= 50; num++) { int sum = 0; for (int i = 1; i &lt;= num / 2; i++) { if (num % i == 0) sum += i; } if (sum == num) printf(&quot;%d is a perfect number\n&quot;, num); } return 0; } This code checks each number from 1 to 50 and prints out the perfect numbers found in that range.


Make a C programming that displays the first four perfect numbers?

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.


How do you write a C program to Print 1st 30 Perfect numbers starting from 0?

int i; for (i=2; i&lt;=30; i+=2) printf ("%d\n", i);


The max number of functions you have used in a c program?

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.


How do you write a C program to check whether the number is odd or even Ps-using DEV complier?

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.

Related Questions

Write a program number as a peimeter and checks whether it is perfect or not in java?

class perfect{public static void main(int n) // input as parameter{int a=0;for(int i=1;i


Write a c program using while loop to accept a number check and display message whether number is perfect or not?

The program is here guys.......... //Finding whether the given number is perfect or not //Starts here #include&lt;stdio.h&gt; void main() { int i=1,temp=0,number; scanf("%d",&amp;number); while(i&lt;=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


Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


What is a number that is odd and it's a perfect number?

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.


How do you write a C program to find out perfect numbers from 1 and 50?

To find perfect numbers between 1 and 50 in a C program, you can iterate through each number in that range and check if it is equal to the sum of its proper divisors. A perfect number is defined as a number that is equal to the sum of its positive divisors, excluding itself. Here's a basic outline of the program: #include &lt;stdio.h&gt; int main() { for (int num = 1; num &lt;= 50; num++) { int sum = 0; for (int i = 1; i &lt;= num / 2; i++) { if (num % i == 0) sum += i; } if (sum == num) printf(&quot;%d is a perfect number\n&quot;, num); } return 0; } This code checks each number from 1 to 50 and prints out the perfect numbers found in that range.


Write a program By using if else statement to read a number and check whether it is positive or negative?

write a c++program by using if statement to read a number and check whether it is positive or negative


Is 495 a perfect number?

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.


Is 31 a perfect number?

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.


How can I tell whether a number is a square number?

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.


Make a C programming that displays the first four perfect numbers?

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.


What are perfact 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.


Is 32 an almost perfect number?

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}.