source file name: PrimeFor.C
#include <stdio.h>
int main()
{
int d, no;
int flag=1;
// clrscr();
printf("\n enter any no: ");
scanf("%d",&no);
for(d= 2; d < no; d++)
{
if((no%d) == 0)
{
flag = 0;
break;
}
}
if (flag == 1)
printf("%d is prime number.", no);
else
printf("%d is not a prime number.", no);
//getch();
return 0;
}
output:
0 Comments
Post a Comment