Wednesday, 15 February 2017

program to show prime number in C++.

Tags

//Prime number program in dev C++.

#include<iostream>

using namespace std;

int main()
{

int i,num;
cout<<"Enter number:-\n";
cin>>num;
if(num==1)
{
cout<<"1 is not a prime number and smallest prime number is 2";
}


for(i=2;i<num;i++)
{

if(num%i==0)
{

cout<<"number is not prime number";
break;

}

}
if(num==i)

{

cout<<"number is prime number";

}

return 0;

}