GATE CS 2024 Set 2 — Question 43
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+2 / -0.67MediumThree-Address CodeIntermediate Code GenerationCompiler Design
Compiler Design → Intermediate Code Generation → Three-Address Code
Last updated
Question
Consider the following expression: . The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).
Which one of the following options fills in the missing entries CORRECTLY?
| (0) | + | ||
| (1) | |||
| (2) | uminus | (1) | |
| (3) | |||
| (4) | / | ||
| (5) | + | (3) | (4) |
| (6) | |||
| (7) | = | (6) | (5) |
Correct answer
(A) (1) =[] s i (3) (0) (2) (6) []= x i
Solution
The expression is .
We can break this down into three-address code (triples):
(1)
(3)
(6)
We can break this down into three-address code (triples):
1.Compute :
(0) + p r2.Access : This requires an array load operation. In triples, this is often denoted as
=[] s i (load from array at index ). This corresponds to triple (1).3.Compute :
(2) uminus (1)4.Compute : This multiplies the result of (0) and (2). So triple (3) is
* (0) (2).5.Compute :
(4) / u w6.Compute the sum:
(5) + (3) (4)7.Assign the result to : The assignment requires an array store operation. The LHS is the target. In the given table, triple (7) is
Thus:= (6) (5), which means "assign the value of (5) to the location defined by (6)". Therefore, triple (6) must define the location . The operation for array store access (l-value) is typically []= x i. (1)
=[] s i(3)
* (0) (2)(6)
[]= x iThis matches Option (A).Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Intermediate Code Generation
2026 Set 2 Q17In C runtime environment, which one of the following is stored in heap?2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q27Consider the following C statements: Which of the following options is/are correct? [figure]2026 Set 1 Q28Which of the following statements is/are true?2026 Set 2 Q35A lexical analyzer uses the following token definitions - - …