Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q7 of 15
C - Loops
Find the error in this code snippet:
int count = 1;
do
    printf("%d", count);
    count++;
while (count <= 3);
Ado keyword misspelled
BCondition syntax incorrect
CMissing braces causing only printf in loop
DVariable count not declared
Step-by-Step Solution
Solution:
  1. Step 1: Analyze loop body

    Without braces, only the first statement after do is in the loop.
  2. Step 2: Identify effect

    Only printf runs in loop; count++ runs once after loop ends, causing infinite loop.
  3. Final Answer:

    Missing braces causing only printf in loop -> Option C
  4. Quick Check:

    Use braces to group multiple statements in loop [OK]
Quick Trick: Use braces to include multiple statements in loop [OK]
Common Mistakes:
  • Assuming both statements are in loop without braces
  • Ignoring infinite loop risk
  • Misreading condition syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes