Precedence Precedence means how an expression like xRySz Should be evaluated here R and S are different operators If R has the higher precedence than S it will be evaluated as xRy Sz while if S has the higher precedence than R it will be treated as xR ID: 463505
Download Presentation The PPT/PDF document "Precedence and Associativity" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Precedence and Associativity
Precedence:-
Precedence means how an expression like xRySz
Should be evaluated ,here R and S are different operators. If R has the higher precedence than S, it will be evaluated as (xRy)
Sz
, while if S has the higher precedence than R it will be treated as xR(
ySz
) Slide2
.
Associativity:-
Associativity means if an expression like
xRyRz
(where R is a operator such as + or <= ) should be evaluated “left to right”
i.e
(
xRy
)
Rz
or right to left
i.e
xR
(
yRz
)Slide3
.
Operators
in order of precedence
Associativity
(),[]
Left to Right
!,~,++,-(unary),*(indirection),&(address of),size of
Right to Left
*,/,%
Left to Right
<<,>>
Left to Right
<,<=,>=,>
Left to Right
==,!=
Left to Right
&(bitwise AND)
Left to Right
^
Left
to Right
|
Left to Right
&&
Left to Right
||
Left to Right
? :
Right to Left
=,+=,-= etc
Right
to Left
,
Left to Right