Bird
0
0

What will be the output of the following C code?

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

    The loop runs from i = 1 to i = 5.
  2. Step 2: Understand the condition

    If i is even (i % 2 == 0), the continue statement skips the rest of the loop body.
  3. Step 3: Determine printed values

    Only odd numbers (1, 3, 5) are printed.
  4. Final Answer:

    1 3 5 -> Option B
  5. Quick Check:

    Even numbers skipped, odd numbers printed [OK]
Quick Trick: continue skips current iteration [OK]
Common Mistakes:
  • Assuming continue skips all iterations
  • Printing even numbers instead of odd
  • Ignoring the continue statement effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes