Bird
0
0

What is the output of this C code?

medium📝 Predict Output Q13 of 15
C - Loops
What is the output of this C code?
for (int i = 1; i <= 2; i++) {
for (int j = 1; j <= 3; j++) {
printf("%d%d ", i, j);
}
}
A12 13 21 23
B11 12 13 21 22 23
C123 123
D11 21 12 22 13 23
Step-by-Step Solution
Solution:
  1. Step 1: Trace outer loop iterations

    Outer loop runs i=1 and i=2.
  2. Step 2: Trace inner loop for each outer iteration

    For i=1, inner loop prints 11 12 13; for i=2, inner loop prints 21 22 23.
  3. Final Answer:

    11 12 13 21 22 23 -> Option B
  4. Quick Check:

    Nested loops print pairs in order [OK]
Quick Trick: Outer loop controls first digit, inner loop second digit [OK]
Common Mistakes:
  • Mixing order of printed pairs
  • Printing numbers without spaces
  • Confusing loop limits

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes