Sunday, 23 December 2012

prime no


PRIME NO

#include<stdio.h>
int main()
{
int n,c;
printf("enter the no\n");
scanf("%d",&n);
if(n==2)
{
printf("prime\n");
}
else
{
for(c=2;c<=n-1;c++)
{
if(n%c==0)
{
break;
}
}
if(c!=n)
{
printf("not prime\n");
}
else
{
printf("prime\n");
}
}
}


No comments:

Post a Comment