Bird
0
0

How can you modify a while loop to skip printing the number 5 but print numbers 1 to 7?

hard📝 Application Q9 of 15
C - Loops
How can you modify a while loop to skip printing the number 5 but print numbers 1 to 7?
AUse <code>if (i == 5) continue;</code> inside the loop.
BUse <code>if (i == 5) break;</code> inside the loop.
CRemove the condition for i == 5.
DUse <code>if (i != 5) break;</code> inside the loop.
Step-by-Step Solution
Solution:
  1. Step 1: Understand skipping iteration

    To skip printing 5, use continue to skip current loop iteration.
  2. Step 2: Check options

    Use if (i == 5) continue; inside the loop. uses continue correctly; break stops loop early, others incorrect.
  3. Final Answer:

    Use if (i == 5) continue; inside the loop. -> Option A
  4. Quick Check:

    Continue skips current iteration [OK]
Quick Trick: Continue skips current loop iteration [OK]
Common Mistakes:
  • Using break instead of continue
  • Removing condition without skipping
  • Misusing break to skip one value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes