how to find the given number is prime or not?
Answer Posted / rahul tiwari
main()
{
int n,ctr=2,flag=0;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=n/2;ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==1)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
flag=9
getch();
}
| Is This Answer Correct ? | 8 Yes | 7 No |
Post New Answer View All Answers
What is a macro, and explain how do you use it?
Is c a great language, or what?
c program to compute AREA under integral
How can I access an I o board directly?
Explain logical errors? Compare with syntax errors.
What are register variables in c?
Explain bitwise shift operators?
Are global variables static in c?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
What is the function of this pointer?
What is the hardest programming language?
Why is it usually a bad idea to use gets()? Suggest a workaround.
write a program to copy the string using switch case?
Is linux written in c?
Why do we need functions in c?