Bird
0
0

Identify the error in this code:

medium📝 Debug Q7 of 15
C - onditional Statements
Identify the error in this code:
int num = 5;
switch (num) {
  case 1
    printf("One\n");
    break;
  default:
    printf("Default\n");
}
AMissing colon after case 1
BMissing break after default
CMissing semicolon after printf
DMissing parentheses around num
Step-by-Step Solution
Solution:
  1. Step 1: Check case label syntax

    Case labels must end with a colon (:), missing after case 1 here.
  2. Step 2: Verify other syntax

    Break after default is optional, semicolon after printf is present, parentheses around num are correct.
  3. Final Answer:

    Missing colon after case 1 -> Option A
  4. Quick Check:

    Case labels require colon after value [OK]
Quick Trick: Case labels must end with a colon [:] [OK]
Common Mistakes:
  • Forgetting colon after case value
  • Thinking break is mandatory after default
  • Confusing semicolon placement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes