Answer the question
In order to leave comments, you need to log in
Output of prime numbers from 0 to 1000. Where is the error in the code?
#include<iostream>
using namespace std;
int main() {
int n, p;
p = 2;
for (n = 1; n < 1000; n++) {
bool prime = true;
for (p; p < n; p++) {
if (n % p == 0) {
prime = false;
}
}
if (prime == true) {
cout << n << " - Prostoe" << endl;
}
else {
cout << n <<" - Sostavnoe" << endl;
}
}
system("pause");
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question