Output |
using namespace std;
int main()
{
int n, i = 3, count, c;
cout<<"Enter the number of prime numbers required: ";
cin>>n;
if ( n >= 1 ) {
cout<<"First "<<n<<" prime numbers are:\n";
cout<<"2\n";
}
count = 2 ;
while (count <= n) {
for ( c = 2 ; c <= i - 1 ; c++ ) {
if ( i%c == 0 )
break;
}
if ( c == i ) {
cout<<i<<"\n";
count++;
}
i++;
}
return 0;
}
0 comments :
Post a Comment