Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

ISRO | ISRO CS 2011 | Question 40

  • Difficulty Level : Hard
  • Last Updated : 14 May, 2018

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!