Operator Precedence:
Operator precedence is a set of rule used to clarify which operations should be performed first in the given expression. It specifies which operator will be evaluated first.
For example, we have an expression like
a = 7+5*8-(2-3)+2**3
and we want to solve above expressions, first of all we will use the operator precedence rule, it tells us which operator perform the operation on the operands first.
To solve the above expression, we need to see the table of operator precedence to understand with the power of operators.
According above table power of Parentheses () is higher compared to all others operator and Logical AND is less then all other.Now, we will solve the above expression according operator precedence table.
Let's solve it,
a = 7+5*8-(2-3)+2**3
a = 7+5*8+1+2**3
a = 7+5*8+1+8
a = 7+40+1+8
a = 56
In the above solution the operators which highlights with underline are high priority operators according to operator precedence table.
1 Comments
Wow
ReplyDelete