Question

Consider the following expression: x[i]=(p+r)∗−s[i]+u/wx[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).

TripleOpArg 1Arg 2
(0)+pprr
(1)
(2)uminus(1)
(3)
(4)/uuww
(5)+(3)(4)
(6)
(7)=(6)(5)

Which one of the following options fills in the missing entries CORRECTLY?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2024 answer key

Solution

Trace the subexpressions of x[i]=(p+r)∗(−s[i])+u/wx[i] = (p + r) * (-s[i]) + u / w and distinguish r-value array read (=[] s i) from l-value indexed target ([]= x i).

  • Triple (1): Triple (2) applies unary minus (uminus) to (1), so (1) must fetch the r-value of s[i]s[i], represented as =[] s i.
  • Triple (3): Multiplies (0) (p+rp + r) and (2) (−s[i]-s[i]), represented as * (0) (2).
  • Triple (6): Triple (7) assigns (5) (the entire RHS value) to the target (6), so (6) represents the l-value array reference x[i]x[i], written as []= x i.

Hence (A) is the correct combination.

Final answer

Option (A)

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
Question
43 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.