Search This Blog

July 11, 2014

C Program to check Whether a Number is Prime or not

#include <stdio.h>
#include <conio.h>
int main( )
{
int n,c;
printf("Enter a Number\n");
scanf("%d",&n);
if(n==2)
printf("Prime Number\n");
else{
for(c=2;c<=n-1;c++)
{


if(n%c==0)
break;
}
if(c!=n)
printf("Not Prime Number\n");
else
printf("Prime Number\n");
}
getch ( );
return 0;
}

No comments:

Post a Comment

Earn Money From Home