Back to the 2023 paper

Module 4: Intermediate Code Generation, Code Improvement (optimization)

20232m

Three-address code involves
(i) Exactly 3 address
(ii) At most 3 addresses
(iii) No unary operator
(iv) None

Worked SolutionAI Assisted

Answer: (ii) At most 3 addresses

Explanation

A three-address code is an intermediate-code statement of the general form:

result=arg1 op arg2\mathrm{result} = \mathrm{arg}_1\ \text{op}\ \mathrm{arg}_2

Each statement contains at most three operands/addresses: the destination plus at most two source operands. The name comes from the fact that a single 3-address statement involves at most three addresses.

  • It is not exactly 3 addresses — a statement like t = a or t = -a has fewer than three addresses.
  • It can contain a unary operation (e.g. t = -x), so saying "no unary operator" is wrong.
  • Therefore "Exactly 3 address" (i), "No unary operator" (iii), and "None" (iv) are incorrect.

The correct statement is:

(ii) At most 3 addresses\boxed{\text{(ii) At most 3 addresses}}

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.