Bird
0
0

What is the output of the following C code?

medium📝 Predict Output Q13 of 15
C - Loop Control Statements
What is the output of the following C code?
for (int i = 1; i <= 5; i++) {
    if (i == 3) continue;
    printf("%d ", i);
}
A1 2 3 4 5
B1 2 4 5
C1 2 3 4
D2 3 4 5
Step-by-Step Solution
Solution:
  1. Step 1: Analyze loop iterations

    The loop runs i from 1 to 5. When i equals 3, the continue statement skips printing.
  2. Step 2: Determine printed values

    Values 1, 2, 4, and 5 are printed with spaces. The number 3 is skipped.
  3. Final Answer:

    1 2 4 5 -> Option B
  4. Quick Check:

    continue skips printing 3 [OK]
Quick Trick: Skip printing when continue triggers, others print normally [OK]
Common Mistakes:
  • Including the skipped number in output
  • Confusing continue with break
  • Ignoring the loop condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes