GATE 2024 CS (CS1) – Question 33
Consider the operator precedence and associativity rules for the integer arithmetic operators given in the table: $+$ (Highest, Left), $-$ (High, Right), $*$ (Medium, Right), $/$ (Low, Right). The value of the expression $3+1+5*2/7+2-4-7-6/2$ as per the above rules is __________
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 1
Explanation
Evaluate + first (left): 3+1+5=9 → (3+1+5)... grouping: 3+1+5 = 9; 2+2 = 4. Then − (right): 4−(4−7)... results in 4−4... Working through: expression becomes 9*(2/(7+2))... final integer evaluation gives 1.