#include<stdio.h> #include<math.h> main() { int i,flag,n; printf("enter your number:"); scanf("%d",&n); flag=1; for(i=2;i<=sqrt(n);i++) { if(n%i==0) { flag=0; break; } } if(flag==0) printf("\n %d is not a prime number",n); else printf("\n %d is a prime number",n); }
Friday, 10 February 2012
how to check wether the given number is prime or not
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment