Precedence of Operators
|
|
|||
The arithmetic operators in an expression are evaluated
according to their precedence. The precedence means which operator will
be evaluated first and which will be evaluated after that and so on.
In an expression, the parentheses ( ) are used to force the evaluation
order. The operators in the parentheses( ) are evaluated first. If there
are nested parentheses then the inner most is evaluated first. The expressions are always evaluated from left to right. The operators *, / and % have the highest precedence after parentheses. These operators are evaluated before + and – operators. Thus + and – operators has the lowest precedence. It means that if there are * and + operators in an expression then first the * will be evaluated and then its result will be added to other operand. If there are * and / operators in an expression (both have the same precedence) then the operator which occurs first from left will be evaluated first and then the next, except you force any operator to evaluate by putting parentheses around it. |
||||
|
Previous |
TOC |
Next |
|