What is the output of the following segment of code if the value 4 is input by the user?
int num;
int total = 0;
cout << "Enter a number from 1 to 10: ";
cin >> num;
switch (num)
{
case 1:
case 2:
total = 5;
case 3:
total = 10;
case 4:
total = total + 3;
Case 8:
total = total + 6;
default:
total = total + 4;
}
cout << total << endl;
A) 0
B) 3
C) 13
D) 23
E) None of these
Correct Answer:
Verified
Q24: What is the value of the following
Q36: This operator takes an operand and reverses
Q37: What is the value of result
Q39: What is the value of donuts
Q40: Which of the following expressions will determine
Q42: When a program lets the user know
Q43: This statement uses the value of a
Q44: The default section of a switch statement
Q45: Given the if/else statement:
If (a < 5)
B
Q46: Input values should always be checked for
A)
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents