Integer value, n Set value = 32, n = 1 while(value greater than equal to n) value = value >> 1 end loop Print value
(A)
16
(B)
32
(C)
64
(D)
0
Answer: (D)
Explanation:
Firstly variables n and value are initialized, then n and value are assigned values 1 and 32 respectively.
Now run a while loop will until the value becomes lesser than 1, in each iteration of the loop perform a right shift by 1(divide by 2) operation on the value variable.
Thus the value changes in order 32, 16, 8, 4, 2, 1, 0 till here the value 0 is smaller than 1 so the while loop terminates.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Article Tags :
Uncategorized
Recommended Articles