Vidyalelo
C++ Programming · Q3

Control Flow Statements in C++

Programming · C++ Programming · question 3

Q3

What is the correct syntax for the 'switch' statement in C++?

A.
switch (expression) { case constant1: statement1; case constant2: statement2; }
B.
switch (expression) { case constant1: statement1; break; case constant2: statement2; break; default: defaultStatement; }
Answer
C.
switch (expression) { case constant1: statement1; default: defaultStatement; }
D.
None of the above

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board