Students often know the definitions of three-address code, quadruples and triples, yet lose marks when a named temporary becomes a row reference or when a DAG reuses one node. The gap is narrow and it is exactly where the marks go: a quadruple names its result, a triple leaves the result unnamed and cites a row number instead, and a DAG lets two parents share a single node rather than recompute it. Most of the questions here are previous-year papers, drawn from GATE, UGC NET, DSSSB, UPPSC and Coal India. For wider practice around the same unit, continue with the broader Compiler Design MCQs.
3AC, quadruples and triples: what each representation stores
Three-address code (3AC) breaks an expression into instructions containing at most one operator. A quadruple stores each instruction as (op, arg1, arg2, result). A triple stores (op, arg1, arg2) and identifies a computed value by its row number instead of naming a temporary. An indirect triple adds a pointer list, while a DAG shares one node when the same value is reused.
For x = a + b * c, with a = 10, b = 4 and c = 3, precedence gives t1 = b * c = 4 * 3 = 12, followed by x = a + t1 = 10 + 12 = 22. The quadruples are (*, b, c, t1) and (+, a, t1, x). The triples are 0: (*, b, c) and 1: (+, a, (0)), with row 1 supplying the value assigned to x. Place this notation in the wider Compiler Design concept map.

MCQs on why intermediate code exists and what counts as an IR
Question 1 (Coal India 2020)
Generation of intermediate code based on an abstract machine model is useful in compilers because:
A. It makes implementation of lexical and syntax analysis easier
B. It is difficult to generate executable code from high level language program.
C. Syntax translations are easier for intermediate code generation
D. It enhances the portability of the compiler system programAnswer: D. The front end can produce the same machine-independent IR while different back ends target different architectures. Lexing and parsing precede IR generation, so IR does not simplify them. Open the live question.
Question 2 (GATE 2021)
In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?
A. Symbol table
B. Three address code
C. Control Flow Graph (CFG)
D. Abstract Syntax Tree (AST)Answer: A. A symbol table stores identifier attributes such as type and scope. An AST, 3AC and a CFG represent program structure or flow. Open the live question.
Question 3 (UGC NET 2023)
One of the purposes of using intermediate code in compilers is to :
A. make parsing and semantic analysis simpler
B. improve error recovery and error reporting
C. increase the chances of reusing the machine independent code optimizer in other compilers
D. improve the register allocationAnswer: C. Several language front ends can lower to one IR, a reusable machine-independent optimizer can process it, and separate back ends can target different machines. Register allocation remains target-sensitive. Open the live question.
MCQs on sequencing 3AC and backpatching jumps
Question 4 (DSSSB 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, TAnswer: D. With A = 14, B = 6, C = 2, D = 3 and E = 2: Y = 14 - 6 = 8, T = 3 * 2 = 6, T = 6 + 2 = 8, then Y = 8 / 8 = 1. A stores the quotient in T, B divides T by itself, and C reads T before defining it. Open the live question.
Question 5 (GATE 2025)
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:
(I) Backpatching can be used to generate code for Boolean expressions in one pass.
(II) Backpatching can be used to generate code for flow-of-control statements in one pass.
Which ONE of the following options is CORRECT?
A. Only (I) is correct.
B. Only (II) is correct.
C. Both (I) and (II) are correct.
D. Neither (I) nor (II) is correct.Answer: C. Backpatching keeps unresolved targets in truelist, falselist and nextlist, then fills them when addresses become known. It supports one-pass generation for Boolean expressions and control-flow statements. Open the live question.
MCQ on array-address arithmetic in intermediate code
Question 6
Consider a program is accessing an array location A[i][j]. The following intermediate code is generated by the compiler.
t1 = i * 16
t2 = j * 4
t3 = t1 + t2
t4 = A[t3]
Assuming that the size of an integer is 4 Bytes and size of an element is 1 Byte.
Which of the following statement is Correct?
A. A is declared as int A[4][3]
B. A is declared as char A[4][3]
C. A is declared as int A[3][4]
D. A is declared as char A[3][4]Answer: C. The stem's stray line about a 1-byte element contradicts its own code, so read the strides. j * 4 means 4 bytes per element, which is int. Each 16-byte row has 16 / 4 = 4 columns. For i = 2, j = 3, the code gives t1 = 32, t2 = 12, t3 = 44; the formula confirms (2 * 4 + 3) * 4 = 44. Strides do not reveal the row count, but int A[3][4] is the matching option. Open the live question.
MCQs on quadruple and triple representation
Question 7 (UGC NET 2023)
Three address codes can be represented in special structures known as :
(A) Quadruples
(B) Triples
(C) Patterns
(D) Indirect Triples
Choose the correct answer from the options given below :
A. (A) and (B) Only
B. (A), (B) and (D) Only
C. (B) and (C) Only
D. (B), (C) and (D) OnlyAnswer: B. Quadruples name results, triples use row positions, and indirect triples add a pointer list. “Patterns” is not a standard 3AC record representation. Open the live question.
Question 8 (UGC NET 2019)
On translating the expression given below into quadruple representation, how many operations are required?
(i * j) + (e + f) * (a * b + c)
A. 5
B. 6
C. 3
D. 7Answer: B. The six operations are t1 = i * j; t2 = a * b; t3 = t2 + c; t4 = e + f; t5 = t4 * t3; t6 = t1 + t5. Their quadruples are (*, i, j, t1), (*, a, b, t2), (+, t2, c, t3), (+, e, f, t4), (*, t4, t3, t5) and (+, t1, t5, t6). Each binary operator creates one row. Open the live question.
Question 9 (GATE 2024)
Consider the following expression: x[i] = (p + r) * -s[i] + u/w. The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).
| Triple | op | arg1 | arg2 |
|--------|--------|------|------|
| (0) | + | | |
| (1) | | | |
| (2) | uminus | (1) | |
| (3) | | | |
| (4) | / | u | w |
| (5) | + | (3) | (4) |
| (6) | | | |
| (7) | = | (6) | (5) |
Which one of the following options fills in the missing entries CORRECTLY?
A. (1) =[] s i (3) * (0) (2) (6) []= x i
B. (1) []= s i (3) - (0) (2) (6) =[] x (5)
C. (1) =[] s i (3) * (0) (2) (6) []= x (5)
D. (1) []= s i (3) - (0) (2) (6) =[] x iAnswer: A. (1) =[] s i loads s[i]; (2) negates it; (3) * (0) (2) multiplies (p + r) by -s[i]. (6) []= x i identifies destination x[i], and (7) stores result (5) there. Open the live question.
MCQs on DAG evaluation and shared nodes
Question 10 (UPPSC Polytechnic Lecturer 2022)
The value of the following hierarchical representation (DAG) is ............
(+)
||
(.)
/ \
2 3
A. 11
B. 7
C. 12
D. 8Answer: C. The shared node gives 2 * 3 = 6. Two parallel links feed that value to +, so the root gives 6 + 6 = 12. Sharing avoids recomputation, not the second use. Open the live question.

Question 11
Consider the statements.
S1: In a DAG representation of expression leaves corresponds to atomic operands and interior nodes corresponds to the operators.
S2: A node in DAG may never have multiple parents.
Which of the above statements is/are False?
A. Only S1
B. Only S2
C. Both S1 and S2
D. Neither S1 nor S2Answer: B. S1 gives the usual expression DAG layout. S2 is false. For x = a + b and y = a + b, one shared node for a + b can feed both uses, so it may have multiple parents. Open the live question.
3AC, quadruples and triples: six traps and your next step
Keep six traps visible while solving:
Respect precedence before emitting 3AC.
Never read a temporary before defining it.
Remember that triples use row references.
Derive array shape from byte strides.
Count one quadruple for each primitive operation.
Treat multiple parents as a DAG feature, not an error.
More than thirty questions on 3AC, quadruples and triples sit behind those practice links, so keep going: solve cold first, read the derivation second. For the wider syllabus, use the GATE CS Exam Preparation Courses & Test Series, then take GATE Guidance by Sanchit Sir as the structured next step. Continue with Parsing MCQs: 12 solved questions on top-down and bottom-up parsing for adjacent practice.




