Advertisement
rorschack

c++ cw prog - prime no. list

Aug 16th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3.  
  4. void main()
  5. {
  6.     clrscr();
  7.     short unsigned int enu(1);
  8.     bool prime;
  9.     cout << "List of prime nos. from 1-100.\n\n";
  10.     for (int j(2); j<=100; j++)
  11.     {
  12.         prime = 0;
  13.         for (int i(2); i<j; i++)
  14.         {
  15.             if(j % i == 0)
  16.             {
  17.                 prime = 1;
  18.                 break;
  19.             }
  20.         }
  21.         if(prime == 0)
  22.         {
  23.             cout << enu << ".\t" << j << endl;
  24.             enu++;
  25.         }
  26.     }
  27.     getch();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement