42 Programming and Data Structures
&& Logical AND
Left to right
11th
| | Logical OR
Left to right
12th
?: Conditional operator
Right to left
13th
=, *»,- =/ &=,+*
, |«, <<=, >>= Assignment Operators
Right to left 14th
Comma operator Left to right
15th
1) When two operators of the same priority are found in the expression, precedence is given to
the extreme left operator.
Example x= 5
2;
3
Here, 5*4 is solved first. Though * and / have the same priorities. The operator * occurs before /.
2) If there are more sets of parenthesis in the expression, the innermost parenthesis will be solved
first, followed by the second and so on.
Example ( 8 / ( 2 * ( 2 * 2 )));
1
2
3
Here,
a) Innermost bracket is evaluated first i.e. 2*2=4.
b) Second innermost bracket is evaluated. 2 is multiplied with result of innermost bracket. The
answer of 2*4=8.
c) The outer most is evaluated. 8 is divided by 8 and gives result 1.
Example
X k =
u
1
5
8
7