What is the output of the following segment of code if 4 is input by the user when asked to enter a number?
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) 28
E) None of these
Correct Answer:
Verified
Q1: What will the following segment of
Q4: After execution of the following code,
Q4: When a relational expression is false, it
Q5: Relational operators allow you to _ numbers.
A)
Q5: Whereas < is called a relational operator,
Q6: What is assigned to the variable a
Q7: What will be the output of
Q9: What will following segment of code
Q10: This statement lets the value of a
Q34: This operator represents the logical AND:
A) ++
B)
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