Bird
0
0

Find the problem in this code snippet:

medium📝 Debug Q7 of 15
C - Loops
Find the problem in this code snippet:
int count = 0;
while (count < 3) {
    printf("%d", count);
}
ACondition should be count <= 3
BMissing increment of count causes infinite loop
CSyntax error in printf statement
DNo problem, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check loop variable update

    The variable count is never incremented inside the loop.
  2. Step 2: Understand loop behavior

    Without increment, condition remains true forever, causing infinite loop.
  3. Final Answer:

    Missing increment of count causes infinite loop -> Option B
  4. Quick Check:

    Loop variable must change to avoid infinite loop [OK]
Quick Trick: Always update loop variable inside while loop [OK]
Common Mistakes:
  • Forgetting to increment
  • Assuming loop ends automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes