Thursday, August 19, 2010

C Programming - check the number is prime

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,count=0;
clrscr();
printf("\n enter the number=");
scanf("\n %d",&n);
for(i=2;i {
if(n%i==0)
count++;
}
if(count==0)
printf("\n %d is prime number",n);
else
printf("%d is not prime number",n);
getch();
}

output:-enter the number =23
23 is prime number

No comments:

Post a Comment