#include <iostream.h> #include <conio.h> int main() { int count=0; for (int i=1; i<=100; i++) { for(int k=i; k>=1; k--) { if(i%k==0) { count++; } } if(count==1 || count==2) { cout << i << endl; } count=0; } getch(); return 0; }
Output:
Search Tags: c++ programs, cpp programs, c++ practice programs, cpp practice programs, prime numbers