🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित कोड स्निपेट का आउटपुट क्या होगा?

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)
B)
C)
D)

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:

  1. Outer loop (over i): Runs 3 times (from i = 0 to i = 2).
  2. Inner loop (over j): Runs 2 times for each iteration of i (from j = 0 to j = 1).
  3. The printf prints the values of i and j in the format i j without spaces.

Let's go through the iterations:

  • When i = 0, j will take values 0 and 1, so the output will be 00 and 01.
  • When i = 1, j will take values 0 and 1, so the output will be 10 and 11.
  • When i = 2, j will take values 0 and 1, so the output will be 20 and 21.

Thus, the final output will be: 0001 1011 2021.

Correct Answer:

(B) 000110112021.

Latest Updates