how to find the given number is prime or not?
Answer Posted / shrikanth s.hallikhed
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,flag=0,ctr;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=sqrt(n);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");
getch();
}
Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
There seem to be a few missing operators ..
What is bubble sort in c?
Why doesnt long int work?
explain how do you use macro?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
What is a example of a variable?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
Is it fine to write void main () or main () in c?
How the c program is executed?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
Can you explain the four storage classes in C?
Why is c fast?
What is the use of parallelize in spark?
Why does not c have an exponentiation operator?
What is function prototype in c language?