Bird
0
0

Why does the continue statement not cause an infinite loop when used correctly inside a while loop?

hard📝 Conceptual Q10 of 15
C - Loop Control Statements
Why does the continue statement not cause an infinite loop when used correctly inside a while loop?
ABecause the loop variable is updated before continue is executed
BBecause continue exits the loop immediately
CBecause continue pauses the loop until a condition is met
DBecause continue resets the loop variable automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand continue's effect on loop flow

    Continue skips remaining code in the iteration but does not change loop variables.
  2. Step 2: Prevent infinite loop by updating loop variable first

    Updating the loop variable before continue ensures the loop progresses and eventually ends.
  3. Final Answer:

    Because the loop variable is updated before continue is executed -> Option A
  4. Quick Check:

    Update variable before continue to avoid infinite loop [OK]
Quick Trick: Update loop variable before continue to avoid infinite loops [OK]
Common Mistakes:
  • Assuming continue exits loop
  • Not updating loop variable before continue
  • Thinking continue resets variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes