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