Skip to content
Related Articles

Related Articles

GATE | GATE CS Mock 2018 | Question 38
  • Last Updated : 04 Dec, 2019

Consider the following source code :

c = a + b
d = c
c = c – e
a = d – e
b = b * e
b = d/b

Which of the following is correct optimization of given code?
(A)

c = a + b
      t = b * e
      a = d – e
      b = d/t
      c = a

(B)

c = a + b
      d = c
      c = c – e
      a = d – e
      b = d/b

(C)

d = c
     c = c – e
     a = d – e
     b = b * e
     b = d/b

(D) None of the above


Answer: (D)

Explanation: (A) It modified by a = d – e, but d must contain a+b.
(B) It used old value of b but b = b*e.
(C) Variable d used old value of c, but d = a+b.

All optimizations are not correct. Option (D) is correct choice.

Quiz of this Question

sudo-gate-course

My Personal Notes arrow_drop_up
Recommended Articles
Page :