What will be the value of i in the next pseudocode?
I got this question in a programming test. Do you think this question is even correct? Look at the answer options. (2 ^ x means 2 raised to x)
Consider the following pseudocode.
x: = 1;
i: = 1;
whereas (x> = 1000)
start
x: = 2 ^ x;
i: = i + 1;
end;
What is the value I am at the end of the pseudocode?
a) 4
b) 5
c) 6
d) 7
e) 8
I'm sure there i
will be value 1
. I told the examiner about the discrepancy and he advised me to leave the question unanswered if I felt it was not correct. What else could I do?
source to share
This question checks two things:
- can you read the code
- You can chat / interact
Since you asked about the inconsistency, you showed 1. to be true. I'm not sure if you passed 2 it is too much dependent on the situation / expectations.
I suppose I would leave a note on the answer sheet that says "none of the data".
Not an easy situation!
source to share
If I am where you are, I would say it is none of the above, and basically say that since x is less than 1000 when the while loop starts, the value of I never changes. I think it's a bad assignment to leave blank answers in the quiz, it's always best to write what you think matters. If you think there is a bug, you can always specify a guess before quoting your answer, so in this case, you can say that the while loop never works, otherwise you explicitly state a guess, in which case it is something like " Assuming there is a mistake in the question, and that "while (x> = 1000)" should actually be "while (x <= 1000)" ... Then you will continue your work.
source to share