Open In App

ISRO | ISRO CS 2007 | Question 15

Like Article
Like
Save
Share
Report

Consider the following pseudo-code

x:=1;
i:=1;
while (x <= 1000)
begin
  x:=2^x;
  i:=i+1;
end;

What is the value of i at the end of the pseudo-code?

(A) 4
(B) 5
(C) 6
(D) 7


Answer: (B)

Explanation: Initialisation: x = 1, i = 1;

Loop: x       i
     21       2
     22       3
     24       4
     216      5

After this condition becomes false.

So, i = 5, Option (B) is correct.

Quiz of this Question


Last Updated : 21 Jun, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads