ProgrammingModerateTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
function triple(ref Integer x)   // pass by reference
    x = x * 3
end function
Integer a = 5
triple(a)
triple(a)
Print a
  1. A. 15
  2. B. 5
  3. C. 30
  4. D. 45

Correct answer: D. 45

The reference changes a itself each call: 5 -> 15 -> 45.

More Pseudocode and Code Tracing questions

Exams that ask this topic