Bird
0
0

What happens if none of the case labels match the switch expression and there is no default case?

easy📝 Conceptual Q1 of 15
C - onditional Statements
What happens if none of the case labels match the switch expression and there is no default case?
AThe program throws a compile-time error
BThe program executes the first case by default
CThe program executes the code after the switch block
DThe program enters an infinite loop
Step-by-Step Solution
Solution:
  1. Step 1: Understand switch behavior without matching case

    If no case matches and no default is present, the switch block is skipped.
  2. Step 2: Check what happens after switch

    The program continues executing the code after the switch block normally.
  3. Final Answer:

    The program executes the code after the switch block -> Option C
  4. Quick Check:

    Switch no match without default = continue after switch [OK]
Quick Trick: No matching case and no default skips switch block [OK]
Common Mistakes:
  • Assuming a compile error occurs
  • Thinking the first case runs by default
  • Believing it causes an infinite loop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes