#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n, x;
cout<<"Enter a number :";
cin>>n;
for(int i=2; i<=n/2; i++)
{
x=n%i;
if(x==0)
{
cout<<"\nNon-prime number";
i=n+1;
}
}
if(x>0)
cout<<"\nPrime number";
getch();
}
.................................................................
OUTPUT:(click on image to enlarge)
.................................................................
OUTPUT:(click on image to enlarge)
No comments:
Post a Comment