The biggest difference is that a do/while() loop will always be executed at least once. A while() loop and a for() loop may fail to run at all if the condition initially evaluates to false.
Thanks!
so in that case, the code above will let me enter a number at least once, right?
what about the condition? When will the loop quit executing the cin statement?
When will the loop quit executing the cin statement?
It may never end, depending on what you entered into the cin statement. But if you enter an integer that causes the condition statement to evaluate to false the while will end.
Thank you for your help! I read the links and they were very helpful.
I am sorry if I didn't use any code tags. I am new to the website and I think it will take some time to get used to it :P
They check to see if the condition is true. Your minor example also fails as it sets answer to 34, and if you meant answer == 34 it is still evaluating if it is true or not. If it is true it will loop again, if it is false it jumps out of the loop.