Bird
0
0

What will be the output of this C code?

medium📝 Predict Output Q13 of 15
C - Loops
What will be the output of this C code?
int i;
for(i = 1; i <= 3; i++) {
    printf("%d ", i);
}
A0 1 2 3
B1 2 3 4
C1 2 3
D3 2 1
Step-by-Step Solution
Solution:
  1. Step 1: Analyze loop range and iterations

    The loop starts at i=1 and runs while i is less than or equal to 3, so it runs for i=1, 2, 3.
  2. Step 2: Determine printed output

    Each iteration prints the current i followed by a space, so output is "1 2 3 "
  3. Final Answer:

    1 2 3 -> Option C
  4. Quick Check:

    Loop prints 1 to 3 = 1 2 3 [OK]
Quick Trick: Check loop start, end, and printed values carefully [OK]
Common Mistakes:
  • Starting loop from 0 instead of 1
  • Including extra numbers beyond 3
  • Printing in reverse order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes