ProgrammingEasyAccenture · Cognizant pattern

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer x = 10
if (x > 5)
    x = x * 2
else
    x = x + 2
end if
if (x > 15)
    x = x - 3
end if
Print x
  1. A. 9
  2. B. 17
  3. C. 20
  4. D. 12

Correct answer: B. 17

x > 5, so x becomes 20. The second if is a separate test: 20 > 15, so x becomes 17.

More Pseudocode and Code Tracing questions

Exams that ask this topic