What will be the value of i in the following pseudocode?

Posted by user283403 on Stack Overflow See other posts from Stack Overflow or by user283403
Published on 2010-04-12T12:01:57Z Indexed on 2010/04/12 12:13 UTC
Read the original article Hit count: 224

Filed under:
|
|

I got this question in a programming test. Do you think this question is even correct? Look at the answer choices. (2^x means 2 raised to x)

Consider the following pseudocode.
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 pseudocode?

a) 4
b) 5
c) 6
d) 7
e) 8

I am sure that the value of i will 1. I told the examiner of the discrepancy and he advised me the leave the question unanswered if I felt it was incorrect. What else could I have done?

© Stack Overflow or respective owner

Related posts about programming

Related posts about test