Need a project done?

C++ Programming Developer

Search This Blog

Prime numbers C++


#include <iostream>
using namespace std;

int main(){
bool check = true;
//All prime numbers till 100.
for (int num = 2; num<=100; num++){
for (int j=2; j<num; j++){
if (num%j == 0){
check = false;
}
}
if (check == true){
cout << num << endl;
}
check = true;
}
return 0;
}

No comments:

Post a Comment

"Don't let anyone ever make you feel like you don't deserve what you want."