Note: 1 is not a prime number. Prime numbers starts with 2.
Program:
// Program By http://solutionscpp.blogspot.com// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com
#include <iostream>
using namespace std;
int main()
{
int n=0, check=0;
cout << "Enter Number: ";
cin >> n;
for(int i=2;i<=n/2;++i)
{
if(n%i==0)
{
check=1;
break;
}
}
if (check==0)
cout << "This is a prime number";
else
cout << "This is not a prime number";
return 0;
}
0 comments: