#include <stdio.h>
#include<conio.h>
void main()
{
int number ,k,flag,rem;
clrscr();
printf("Enter a number
");
");
scanf("%d",number);
k=2;
flag=1;
while((k<=number-1)&&(flag==1))
{
rem=number%k;
if(rem==0)
flag=0;
k++;
}
if(flag==1)
printf("%d is prime
",number);
",number);
else
printf("%d is not prime
",number);
",number);
getch();
}
OUTPUT
Enter a number
7
7 is prime
Enter a number
8
8 is not prime