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)?
- A.
SUB Y, A, B
MPY T, D, E
ADD T, T, C
DIV T, Y, T - B.
SUB Y, A, B
MPY T, D, E
ADD T, T, C
DIV Y, T, T - C.
SUB Y, A, B
ADD T, T, C
MPY T, D, E
DIV Y, Y, T - D.
SUB Y, A, B
MPY T, D, E
ADD T, T, C
DIV Y, Y, T
Attempted by 78 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.