A blog to help students to learn programming in various languages including C, C++, Java, Python and many more.

Subscribe For Free Latest Updates!

We'll not spam mate! We promise.

Monday, 18 January 2016



Program ScreenShot
Output

#include <iostream.h>

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



Copyright © 2016 - ProgrmIt - All Rights Reserved
(Articles Cannot Be Reproduced Without Author Permission.)
Design By : | Powered By: Blogger