निम्नलिखित प्रोग्राम का आउटपुट क्या है:
What is the output of the following program:
i = 0
while i < 3:
print (i)
i=i+1
print (i+1) A
0 2 1 3 2 4
B
0 1 2 3 4 5
C
Infinite loop
D
0 1 2 3
Explanation
The code prints two numbers in each loop iteration: the current value of i and i + 1.
- First,
i = 0→ prints0and2 - Then,
i = 1→ prints1and3 - Finally,
i = 2→ prints2and4
So, the output is 0 2 1 3 2 4.
The correct answer is (A) 0 2 1 3 2 4.
Correct Answer: A) 0 2 1 3 2 4