Exercises
-
5.5 Describe the four basic elements of counter-controlled iteration.
-
5.6 Compare and contrast the
while
andfor
iteration statements. -
5.7 Discuss a situation in which it would be more appropriate to use a
do
…while
statement than awhile
statement. Explain why. -
5.8 Compare and contrast the
break
andcontinue
statements. -
5.9 (Find the Code Errors) Find the error(s), if any, in each of the following:
For (unsigned int x{100}, x >= 1, ++x) { cout << x << endl; }
The following code should print whether integer
value
is odd or even:switch (value % 2) { case 0: cout << "Even integer" << endl; case 1: cout << "Odd integer" << endl;}
The following code should output the odd integers from 19 to 1:
for (unsigned int ...
Get C++ How to Program, 10/e 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.