What is the printout of the following switch statement? char ch = \'b\'; switch
ID: 3692436 • Letter: W
Question
What is the printout of the following switch statement?
char ch = 'b';
switch (ch)
{
case 'a':
cout << ch << endl;
case 'b':
cout << ch << endl;
case 'c':
cout << ch << endl;
case 'd':
cout << ch << endl;
default:
cout<< "Error" << endl;
}
bb
b
bcd
bbb
abcd
What is the number of iterations in the following loop:
for (int i = 1; i < n; i++)
{
// iteration
}
2*n
n
n + 1
n - 1
How many times the following code prints "Welcome to C++"?
int count = 0;
while (count < 10)
{
cout << "Welcome to C++";
count++;
}
8
10
9
11
0
bb
b
bcd
bbb
abcd
What is the number of iterations in the following loop:
for (int i = 1; i < n; i++)
{
// iteration
}
2*n
n
n + 1
n - 1
How many times the following code prints "Welcome to C++"?
int count = 0;
while (count < 10)
{
cout << "Welcome to C++";
count++;
}
8
10
9
11
0
Explanation / Answer
The switch statement prints out b.
The number of iterations in the for loop is n.
The code prints "Welcome to C++" 10 times.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.