Which of the following sequences of three-address instructions can be used to…

2018

Which of the following sequences of three-address instructions can be used to evaluate Y = (A-B)/(C+D*E)?

Answer: D. SUB Y, A, B MPY T, D, E ADD T, T, C DIV Y, Y, TFirst, compute the numerator A minus B and store it in a temporary variable. Next, calculate D multiplied by E, then add C to that result for the denominator.…

  1. A.

    SUB Y, A, B
    MPY T, D, E
    ADD T, T, C
    DIV T, Y, T

  2. B.

    SUB Y, A, B
    MPY T, D, E
    ADD T, T, C
    DIV Y, T, T

  3. C.

    SUB Y, A, B
    ADD T, T, C
    MPY T, D, E
    DIV Y, Y, T

  4. D.

    SUB Y, A, B
    MPY T, D, E
    ADD T, T, C
    DIV Y, Y, T

Attempted by 161 students.

Show answer & explanation

Correct answer: D

First, compute the numerator A minus B and store it in a temporary variable. Next, calculate D multiplied by E, then add C to that result for the denominator. Finally, divide the numerator value by the denominator value and assign it to Y.

Explore the full course: Hpsc Pgt Computer Science

Loading lesson…