Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q4 of 15
C - onditional Statements
What will be the output of this code?
int n = 3;
switch (n) {
  case 1:
    printf("One\n");
  case 2:
    printf("Two\n");
  case 3:
    printf("Three\n");
  default:
    printf("Default\n");
}
AOne Two Three Default
BThree
CDefault
DThree Default
Step-by-Step Solution
Solution:
  1. Step 1: Identify matching case

    Variable n is 3, so case 3 matches and execution starts there.
  2. Step 2: Check for break statements

    No break after case 3, so execution falls through to default case printing both lines.
  3. Final Answer:

    Three Default -> Option D
  4. Quick Check:

    Switch without break falls through [OK]
Quick Trick: No break causes fall-through to next cases [OK]
Common Mistakes:
  • Assuming only case 3 prints
  • Expecting break after each case by default
  • Ignoring fall-through behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes