November 2001
Beginner
1128 pages
29h 12m
English
| 1: | What's the difference between an entry-condition loop and an exit-condition loop? Which kind is each of the C++ loops? |
| 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: | 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";
|
| A2: | It would print the following:
01234 ... |
Read now
Unlock full access