Bird
0
0

Identify the error in this C loop control code:

medium📝 Debug Q7 of 15
C - Loop Control Statements
Identify the error in this C loop control code:
for(int i = 0; i < 5; i++) {
  if(i == 2) break;
  printf("%d ", i);
}
AVariable i is not declared
BIncorrect loop condition
Cprintf statement is outside the loop
DMissing semicolon after break statement
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of break

    In C, break must be followed by a semicolon.
  2. Step 2: Inspect given code

    The break statement lacks a semicolon after it.
  3. Step 3: Confirm other parts

    Loop condition and variable declaration are correct; printf is inside the loop.
  4. Final Answer:

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

    break must end with semicolon [OK]
Quick Trick: Always end break with semicolon [OK]
Common Mistakes:
  • Omitting semicolon after break
  • Misplacing printf outside loop
  • Incorrect loop condition assumptions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes