Consider the following Three Address Code sample for solving the questions :…

2025

Consider the following Three Address Code sample for solving the questions :

100 : t1 = y+2

101 : initial = x/t1

102 : limit = 10

103 : if i>j goto 105

104 : goto 111

105 : if num>b goto 107

106 : goto 111

107 : num = limit-1

108 : b = y+2

109 : i=i-num

110 : goto 103

111 : j = i-num

112 : k=j+b

Which of the following is the optimized version for the given Three Address Code (TAC) in the passage?

  1. A.

    100 : t1 = y+2

    101 : initial = x/t1

    102 : limit = 10

    103 : if i>j goto 105

    104 : goto 111

    105 : if num>b goto 107

    106 : goto 111

    107 : b = y+2

    108 : i=i-limit-1

    109 : goto 103

    110 : k=i+b

  2. B.

    100 : t1 = y+2

    101 : initial = x/t1

    102 : limit = 10

    103 : if i>j goto 105

    104 : if num<b goto 111

    105 : num = limit-1

    106 : b = t1

    107 : i=i-num

    108 : goto 103

    109 : k=i+b

  3. C.

    100 : t1 = y+2

    101 : initial = x/t1

    102 : limit = 10

    103 : num = 9

    104 : if i>j goto 105

    105 : goto 111

    106 : if num>b goto 107

    107 : goto 111

    108 : i=i-num

    109 : goto 103

    110 : j = i-num

    111 : k=j+t1

  4. D.

    100 : t1 = y+2

    101 : initial = x/t1

    102 : limit = 10

    103 : if i>j goto 105

    104 : goto 111

    105 : if num<b goto 111

    106 : num = limit-1

    107 : b = t1

    108 : i=i-num

    109 : goto 103

    110 : k=i+b

Attempted by 29 students.

Show answer & explanation

Correct answer: D

Dropped question no answer was correct.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor