#include <iostream.h>
#include <conio.h>
#include<process.h>void main()
{
int n, flag = 0, r;
clrscr();
cout<< "\n Enter a number :";
cin>> n;
if(n == 1)
{
cout<< " 1 is neither prime or non-prime no.";
getch();
exit(1);
}
for(int i = 2; i< = n-1 ; i++)
{
r = n%i;
if(r == 0)
{
flag = 1;
break;
}
}
if(flag == 0)
cout<< "\n "<< n << " is a Prime No. ";
else
cout<< "\n "<< n << " is a NON-Prime No. ";
getch();
}
No comments:
Post a Comment