निम्नलिखित कोड स्निपेट का आउटपुट क्या होगा?
What will be the output of the following code snippet?
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
printf("%d%d", i, j);
}
} A
001011020121
B
000110112021
C
000112001122
D
001012011202
Explanation
Let's break down the given code snippet:
Code:
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
printf("%d%d", i, j);
}
}
Explanation:
- Outer loop (over
i): Runs 3 times (fromi = 0toi = 2). - Inner loop (over
j): Runs 2 times for each iteration ofi(fromj = 0toj = 1). - The
printfprints the values ofiandjin the formati jwithout spaces.
Let's go through the iterations:
- When
i = 0,jwill take values0and1, so the output will be00and01. - When
i = 1,jwill take values0and1, so the output will be10and11. - When
i = 2,jwill take values0and1, so the output will be20and21.
Thus, the final output will be: 0001 1011 2021.
Correct Answer:
(B) 000110112021.
Correct Answer: B) 000110112021