The program below uses six temporary variables a, b, c, d, e, f. a = 1 b = 10…

PYQ TPSC Computer/IT Posts 2025Modified — slightly modified from the official paper; see the solution

The program below uses six temporary variables a, b, c, d, e, f. a = 1 b = 10 c = 20 d = a + b e = c + d f = c + e b = c + e e = b + f d = 5 + e return d + f Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling? Assume each operation must place its result in a register distinct from its operand registers until that operation completes; a dead source register can be reused afterward.

  1. A.

    2

  2. B.

    3

  3. C.

    4

  4. D.

    6

Attempted by 272 students.

Sign up free to check your answer

Sign up free

Explore the full course: Tpsc Assistant Technical Officer

Loading lesson…