31.Prime number checking :—
#include<stdio.h>
int main()
{
int i,n,r,count;
printf("enter a value of n ");
scanf("%d",&n);
count=0;
for(i=1;i<=n;i++)
{
r=n%i;
if(r==0)
{
count++;
}
}
if(count==2)
{
printf("It is a prime number");
}
else
{
printf("It is not a prime number");
}
return 0;
}
No comments:
Post a Comment