+ 1
Help!
I may be a chaotic coder but I can't see why my codes are not working: #include <iostream> using namespace std; int main() { int prime=1; int divider=1; int counter; for (prime =1;prime < 10;prime++){ for (counter=1;counter == prime ;counter++){ counter = prime % divider ; } cout<< "prime " << prime << " % " << divider << " = " << counter << endl; } return 0; } Can someone clarify?
3 ответов
+ 2
What should it do?
the condition counter==prime in the second loop is never true when prime is more than 1 (because you set counter to 1), so the inner loop is not executed at all
+ 2
Btw: this program should show all the modulus' between 1/1 and 10/10.
+ 1
Ah, my bad. counter should be divider!