C program to check number is prime or not


#include

void main()
{
int i,j,flag=0,n;
printf(“enter any number\n”);
scanf(“%d”,&n);

for(i=2;i
{
if(n%i==0)
{
flag = 1;
break;
}
}

if(flag==1)
{
printf(“%d is not prime\n”,n);
}
else
{
printf(“%d is a prime number\n”,n);
}

}

0 comments:

Post a Comment