Multiple choice

The output of the following code snippet is ________ ( ) Int iNum=2; Switch(iNum) { case 1.5: printf(ONE AND HALF); Break; case 2: printf(TWO); case 4: printf(FOUR); }

  1. ONE AND HALF

  2. TWO

  3. FOUR

  4. error in code

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

Switch statement case labels must be integer constant expressions, not floating-point values. The value 1.5 is a floating-point literal, which violates C syntax rules for case labels. This causes a compilation error.