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

निम्नलिखित का आउटपुट क्या है?

What is the output of the following ?

i = 2 
while True:
    if i%3 == 0:
       break 
    print(i,end=" " )
    i += 2 

A
2 4 6 8 10 ..
B
2 4
C
2 3
D
error
Explanation

The given code prints values of i starting from 2 and increases i by 2 on each iteration. It prints i until i is divisible by 3. Here's the breakdown:

  1. i = 2: 2 % 3 != 0, prints 2, then i becomes 4.
  2. i = 4: 4 % 3 != 0, prints 4, then i becomes 6.
  3. i = 6: 6 % 3 == 0, the loop breaks.

Output: 2 4

So, the answer is (B) 2 4.

Correct Answer: B) 2 4

Latest Updates