Bird
0
0

Identify the error in the following C code snippet:

medium📝 Debug Q14 of 15
C - Loop Control Statements
Identify the error in the following C code snippet:
int i = 0;
while(i < 5) {
    if(i == 3)
        break
    printf("%d ", i);
    i++;
}
Aprintf statement syntax error
BIncorrect use of break inside while loop
CVariable i is not initialized
DMissing semicolon after break statement
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of break statement

    The break statement must end with a semicolon (;), but it is missing here.
  2. Step 2: Verify other parts

    Variable i is initialized, break is valid inside while, and printf syntax is correct.
  3. Final Answer:

    Missing semicolon after break statement -> Option D
  4. Quick Check:

    break needs semicolon [OK]
Quick Trick: Always end break with semicolon [OK]
Common Mistakes:
  • Forgetting semicolon after break
  • Thinking break can't be inside while
  • Assuming variable i is uninitialized

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes