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?
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.)
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.)
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.)
for (i = 4; i >= 1; i--)
{
for (j = i; j >= 1; j--)
cout << j << ;
cout << i << endl;
}