Open In App

ISRO | ISRO CS 2011 | Question 40

Like Article
Like
Save
Share
Report

Consider the following pseudocode: 
 

x:=1;
i:=1;
while (x ≤ 500)
begin
x:=2x ;
i:=i+1;
end

What is the value of i at the end of the pseudocode?
 

(A)

4
 

(B)

5
 

(C)

6
 

(D)

7
 


Answer: (B)

Explanation:

The program executes as: 

 

In iteration 1: x = 2 and i = 2
In iteration 2: x = 4 and i = 3
In iteration 3: x = 16 and i = 4
In iteration 4: x = 16*16 and i = 5
In iteration 5: Condition incorrect.

So, option (B) is correct. 

 


Quiz of this Question
Please comment below if you find anything wrong in the above post


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