Skip to content
Related Articles

Related Articles

Improve Article

C Quiz – 105 | Question 4

  • Difficulty Level : Basic
  • Last Updated : 28 Jun, 2021

A typical “switch” body looks as follows:




switch (controlling_expression)
{
  case label1:
    /*label1 statements*/
    break;
  case label2:
    /*label1 statements*/
    break;
  default:
    /*Default statements*/
}

Which of the following statement is not correct statement?
(A) “switch” body may not have any “case” label at all and it would still compile.
(B) “switch” body may not have the “default” label and it would still compile.
(C) “switch” body may contain more than one “case” labels where the label value of these “case” is same and it would still compile. If “switch” controlling expression results in this “case” label value, the “case” which is placed first would be executed.
(D) “switch” body may not have any “break” statement and it would still compile.
(E) “switch” body can have the “default” label at first i.e. before all the other “case” labels. It would still compile.


Answer: (C)

Explanation: In “switch” body, two “case” can’t result in same value. Though having only “case” or only “default” is okay. In fact, “switch” body can be empty also.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :