Summary
C++ offers three varieties of loops: the for loop, the while loop, and the do while loop. A loop cycles through the same set of instructions repetitively as long as the loop test condition evaluates to true or nonzero, and the loop terminates execution when the test condition evaluates to false or zero. The for loop and the while loop are entry-condition loops, meaning they examine the test condition before executing the statements in the body of the loop. The do while loop is an exit-condition loop, meaning it examines the test condition after executing the statements in the body of the loop.
The syntax for each loop calls for the loop body to consist of a single statement. However, that statement can be a compound statement, or block, ...
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