C PROGRAM TO CHECK WHETHER A NUMBER IS PRIME OR NOT
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("enter any number");
scanf("%d",&n);
for(i=2;i<n-1;i++)
{
if(n%i!=0)
{
printf("prime\n");
break;
}
if(n%i==0)
{
printf("not prime\n");
break;
}
}
getch();
}
No comments:
Post a Comment