Multiple choice

Which of the following case constants in switch-case is/are not allowed? (a) case ‘S’: and case ‘s’: (b) case a + b: and case a + 3: (c) case i <= 20: (d) case 7 - 3: (e) case 3.14:

  1. only b

  2. b,c and e

  3. a and d

  4. all a,b,c,d and e

  5. none of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Following case statements are invalid:case a+b: and case a+3:case i<=20:case 3.14:Conditional expression, float constant and expressions having variables are not valid. So option 2 is correct answer.