ProgrammingModerateTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
function change(Integer x)
    x = x + 10
    return x * 2
end function
Integer a = 4, b
b = change(a)   // pass by value
Print a, b
  1. A. 4 28
  2. B. 14 28
  3. C. 4 14
  4. D. 14 14

Correct answer: A. 4 28

x is a copy, so a stays 4; the function returns (4 + 10) x 2 = 28.

More Pseudocode and Code Tracing questions

Exams that ask this topic