Template by:
Free Blog Templates

Saturday, November 7, 2009

Check Prime Number C Programming

//wap to check if the no is prime or not
#include
#include
void main()
{int i,n,count=0;;
clrscr();
printf(“\n\n enter a number: “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
  if(n%i==0)
  {count++;}
} //counter
if(count>2)
{printf(“\n%d”,c);}
else
{printf(“\n prime”);}
getch();
}

o/p→
1 enter a number : 55
not prime
2 enter a number : 7
prime


0 comments:

Post a Comment

If you have any proble fee free to ask it here