When several operators are used in the same expression, it might not be obvious how to execute them without established rules. For example, what is the value that is going to be assigned to variable x after the following right-hand expression is evaluated:
int x = 2 + 4 * 5 / 6 + 3 + 7 / 3 * 11 - 4;
We know how to do it because we have learned operator precedence in school—just apply the multiplication and division operators first from left to right, then addition and subtraction from left to right too. But, it turned out that the author actually wanted this sequence of operator execution:
int x = 2 + 4 * 5 / 6 + ( 3 + 7 / 3 * (11 - 4));
It yields a different result.
Operator precedence and parentheses determines the sequence in which parts of an expression are evaluated. The evaluation order of operands defines for each...