Quote Originally Posted by bbomber72000
Since the user is able to enter a value less than, what happens if they enter a max count of less than 5? Our starting value IS 5. We wouldn't want it to run anyway. Not to mention Do While loops are gay.
While, do-while, for, etc. are all equally powerful. You can use any of them to construct the equivalent of any of the others. (Generally, depending how a language is implemented.) All loops are just syntactic sugar over a LOOP / GOTO / END construct when it comes down to it.

Since this is apparently a general C++ thread now, I'll offer some other advice. r1, r2, r3 etc. are very bad choices for variable names. If something stores the modulus of 5, call it at bare minimum "modulus_of_5". If something is a countdown variable, "countdown" is much better than "cd". If you named your variables like this, you wouldn't even need most of the comments you have in your code there. We call it "self-documenting".

Comments should never say WHAT your code is doing. If you can't tell what you're doing in the code just by reading the code, the code probably needs to be rewritten or clarified. Comments should say things like 1) Overall purpose / summary of entire blocks or functions 2) WHY you're doing something (not WHAT you're doing or HOW you're doing it), 3) Anything happening that's subtle or not immediately obvious, 4) Assumptions that are being made about input/output, which your code relies upon. Endless has good comments above. Source code is meant for human beings to read. Machines only understand binary. Good code = easy to read code.

Another piece of advice: if something is a constant (modulus of 5, etc) you should make it a const variable in your code. It prevents accidentally changing the value of the variable. Ideally your program should crash any time anything happens that you didn't anticipate; declaring things as constants is a good way to crash your program. It forces you to correct the problem, and makes it easier to find it to debug. Silent bugs are the worst kind.

So far as finding prime numbers, you could always use the Sieve of Eratosthenes. It's a very simple, famous algorithm for finding primes. I just wrote up a C++ version of it, but then I realized everyone should have the opportunity to enjoy writing it themselves.

*wanders off*