Open In App
Related Articles

C Quiz – 105 | Question 4

Improve Article
Save Article
Like Article

A typical “switch” body looks as follows:

switch (controlling_expression)<br>
  case label1:<br>
    /*label1 statements*/<br>
  case label2:<br>
    /*label1 statements*/<br>
    /*Default statements*/<br>

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 29 Oct, 2021
Like Article
Save Article
Similar Reads