< previous page page_495 next page >

Page 495
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
if (n == 3)
    alpha++;
else if (n == 7)
    beta++;
else if (n == 10)
    gamma++;
6. What is printed by the following code fragment if n equals 3?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
switch (n + 1)
{
    case 2  : cout << Bill;
    case 4  : cout << Mary;
    case 7  : cout << Joe;
    case 9  : cout << Anne;
    default : cout << Whoops!;
}
7. If a While loop whose condition is delta <= alpha is converted into a Do-While loop, the loop condition of the Do-While loop is delta > alpha. (True or False?)
8. A Do-While statement always ends in a semicolon. (True or False?)
9. What is printed by the following program fragment, assuming the input value is 0? (All variables are of type int.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cin >> n;
i = 1;
do
{
    cout << i;
    i++;
} while (i <= n);
10. What is printed by the following program fragment, assuming the input value is 0? (All variables are of type int.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cin >> n;
for (i = 1; i <= n; i++)
    cout << i;
11. What is printed by the following program fragment? (All variables are of type int.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
for (i = 4; i >= 1; i--)
{
    for (j = i; j >= 1; j--)
         cout << j <<  ;
    cout << i << endl;
}

 
< previous page page_495 next page >