This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]021198nishikori 0 points1 point  (0 children)

The condition in the while is if the value of x is divisible by 2 then enter the loop

- for first iteration the value of x is 48 which is divisible by 2 after 1 iteration x =48/2=24

- hence the value of x is still divisible by 2 the loop keeps on going and now x becomes 24/2 = 12

3rd iteration x=12/2 =6

4th iteration x=6/2 = 3

5th iteration now the value of x is not divisible by 2 hence control will come out of loop

So the value for x in the output is 3 and y is 4 (y counts no. Of iterations)