write the program for prime numbers?

Answer Posted / pavankumar

void main()
{
int i=2;
int count=0;
int n;
printf("enter a no");
scanf("%d",&n);
for(i=2;i<n/2;i++)
{
if(n%i==0)
{
count++;
}
if(count>1)
{
prinf("prime");
else
printf("not prime");
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is #define in c?

624


What is the description for syntax errors?

619


Process by which one bit pattern in to another by bit wise operation is?

617


Why is c fast?

612


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

915






Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1123


How do we open a binary file in Read/Write mode in C?

685


What does *p++ do? What does it point to?

620


`write a program to display the recomended action depends on a color of trafic light using nested if statments

1635


How many parameters should a function have?

670


Explain logical errors? Compare with syntax errors.

633


How will you find a duplicate number in a array without negating the nos ?

1650


How was c created?

591


Write a program to find factorial of a number using recursive function.

650


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

656