Summary
There are a number of different ways of causing a C++ program to loop. while loops check a condition, and if it is true, execute the statements in the body of the loop. do...while loops execute the body of the loop and then test the condition. for loops initialize a value and then test an expression. If expression is true, the body of the loop is executed, as is the final statement in the for header. Each subsequent time through the loop, the expression is tested again. The goto statement is generally avoided, because it causes an unconditional jump to a seemingly arbitrary location in the code, thus making source code difficult to understand and maintain. continue causes while, do...while, and for loops to start over, and break causes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access