Review Questions
1: | What's the difference between an entry-condition loop and an exit-condition loop? Which kind is each of the C++ loops? |
2: | What would the following code fragment print if it were part of a valid program?
int i; for (i = 0; i < 5; i++) cout << i; cout << "\n"; |
3: | What would the following code fragment print if it were part of a valid program?
int j; for (j = 0; j < 11; j += 3) cout << j; cout << "\n" << j << "\n"; |
4: | What would the following code fragment print if it were part of a valid program?
int j = 5; while ( ++j < 9) cout << j++ << "\n"; |
5: | What would the following code fragment print if it were part of a valid program?
int k = 8; do cout <<" k = " << k << "\n"; while (k++ < 5); |
6: | Write a for loop that prints the values ... |
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.