Open In App

GATE | GATE CS 1997 | Question 34

Last Updated : 12 Oct, 2020
Like Article
Like
Save
Share
Report

The expression (a*b)* c op……..

where ‘op’ is one of ‘+‘, ‘*‘ and ‘‘ (exponentiation) can be evaluated on a CPU with a single register without storing the value of (a * b) if
(A) ‘op’ is ‘+’ or ‘*’
(B) ‘op’ is ‘↑’ or ‘*’
(C) ‘op’ is ‘↑’ or ‘+’
(D) not possible to evaluate without storing


Answer: (A)

Explanation: Given expression is :-

(a*b)* c op  

Here op is one of the ‘+’, ‘*’ and ‘↑’ (exponentiation).

(a* b)* having high precedence so it will evaluate first in CPU register. But we have given one single register as we cannot store any value from reg to memory.

Now ( a * b ) is evaluated in register R and precedence order is ( ↑ , * or / , + or – ).

If we put op as (a*b)* c op ‘ ↑ ‘ then expression becomes as (a*b)* c ↑ d here c ↑ d will evaluate first. But we have not extra register to evaluate ( a * b ).
Therefore we cannot put any operator having precedence greater than ” * ”.

Hence, Operator is either ” + ” or “- ” .

Quiz of this Question


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads