#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int a,b=0,n;
cout<<"Enter the no. = ";
cin>>n;
for (int i=1;i<=n;i++)
{ a=n%i;
if (a==0)
{ b++;
}
}
if (b==2)
{ cout<<n<<" is a Prime no. ";
}
else
{ cout<<n<<" is not a prime no. ";
}
getch();
}
#include<iostream.h>
void main()
{
clrscr();
int a,b=0,n;
cout<<"Enter the no. = ";
cin>>n;
for (int i=1;i<=n;i++)
{ a=n%i;
if (a==0)
{ b++;
}
}
if (b==2)
{ cout<<n<<" is a Prime no. ";
}
else
{ cout<<n<<" is not a prime no. ";
}
getch();
}
No comments:
Post a Comment