ISRO | ISRO CS 2015 | Question 24
Given the following expression grammar:
E → E ∗ F ∣ F + E ∣ F
F → F − F ∣ id
Which of the following is true?
(A) * has higher precedence than +
(B) – has higher precedence than *
(C) + and – have same precedence
(D) + has higher precedence than *
Answer: (B)
Explanation: For the above expression grammar both * and + have same precedence which can be seen through the following parse trees:
whereas – operator has a higher precedence from both + and * as, – operator will always be executed first along with the operands stored in id and then * or + will be computed.
So, option (B) is correct.
Quiz of this Question
Last Updated :
04 Apr, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...