Wednesday, 15 February 2017

program to find prime number after giving number in C++

Tags

#include<iostream>
using namespace std;
int main ()
{
int i,j,num;
cout<<"Enter number:-";
cin>>num;
cout<<"next prime number:-";
for(i=num+1;i<2000;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
//cout<<"no prime no:-";
break;
}

}
if(i==j||i==0)
{
cout<<"\t"<<i;
break;
}

return 0;

}
}