Chapter 5

1:
A1: An entry-condition loop evaluates a test expression before entering the body of the loop. If the condition initially is false, the loop never executes its body. An exit-condition loop evaluates a test expression after processing the body of the loop. Thus the loop body is executed once even if the test expression initially is false. The for and while loops are entry-condition loops, and the do while loop is an exit-condition loop.
2:
A2: It would print the following:
01234

Note that the cout << "\n"; is not part of the loop body (no braces).

3:
A3: It would print the following:
0369
12
4:
A4: It would print the following:
6
8
5:
A5: It would print the following:
k = 8
6:
A6: It's simplest to use the *= operator: ...

Get The Waite Group's C++ Primer Plus, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.