• edited by
8,159 views
35 35 votes

The expression $( a * b) * c \; op \dots$

where ‘op’ is one of ‘$+$’, ‘$*$’ and ‘$\uparrow$’ (exponentiation) can be evaluated on a CPU with single register without  storing the value of ($a * b$) if

  1. $\text{‘op’}$ is ‘$+$’ or ‘$*$’

  2. $\text{‘op’}$ is ‘$\uparrow$’ or ‘$*$’

  3. $\text{‘op’}$ is ‘$\uparrow$’ or ‘$+$’

  4. not possible to evaluate without storing

2 Answers

Best answer
43 43 votes
Correct Option: A

$\uparrow$ has higer precedence than $\{*,+,-,/ \}$

So, if op $ = \uparrow$ implies, we need to evaluate the right hand side of $\uparrow$ first and then do the lhs part, which would definitely require us to store the value of lhs

but if its a '$+$' or '$*$' , we don't need to store the values evaluated, and on the go can do the operation directly on one register.
• edited by
39 39 votes
Let say, the expression is one of the below:

(a*b)*c+d

(a*b)*c*d

(a*b)*c^d

In any case, brackets has the highest priority always. So I have to compute brackets first. Now, for + and *, I can do the rest of the operation and save results in the same register. But for exponentiation, I have to store the result of a*b, then do the computation of c^d, then multiply these two results.

So option A is correct.
Answer:
Position:
Show:

Related questions

5 5 votes
1 1 answer
2.0k
2.0k views
Kathleen asked Sep 29, 2014
1,973 views
The language $L,$ defined by the following grammar, allows use of real or integer data in expressions and assignment statements.<assign-stmt :: <LHS := <E <E ::...
33 33 votes
4 answers 4 answers
11.5k
11.5k views
Kathleen asked Sep 29, 2014
11,502 views
Consider the grammar$S \rightarrow bSe$$S \rightarrow PQR$$P \rightarrow bPc$$P \rightarrow \varepsilon$$Q \rightarrow cQd$$Q \rightarrow \varepsilon$$R \rightarrow dRe...
28 28 votes
2 answers 2 answers
11.1k
11.1k views
Kathleen asked Sep 29, 2014
11,085 views
In the following grammar$X ::= X \oplus Y \mid Y$$Y::= Z * Y \mid Z$$Z::= id $Which of the following is true?$\text{‘}\oplus\text{’}$ is left associative while $\text{‘}*...
21 21 votes
2 answers 2 answers
7.9k
7.9k views
Kathleen asked Sep 29, 2014
7,897 views
The conditional expansion facility of macro processor is provided totest a condition during the execution of the expanded programto expand certain model statements depend...