Operator precedence and associativity in C language

 Below is the table for operator precedence and associativity in C programming language.

[ ]
( )
.
->
++ --
Array subscript
Function Call
Structure reference
Structure dereference
Postfix increment/Postfix decrement


Left to right
++ --
+ -
! ~
(type)
*  &
sizeof
Prefix increment/Prefix decrement
Unary plus/Unary minus
Logical negation/One's complement
Typecast operator
Pointer dereference/Address of
Size of type/variable in bytes


Right to left
*  /  %Multiplication/Division/ModuloLeft to Right
+ -Addition/SubtractionLeft to Right
<<   >>Bitwise left shift/ Bitwise right shiftLeft to Right
<    >
<=
>=
Comparison less than/Comparision greater than
Comparison less than or equal to
Comparison greater than or equal to

Left to Right
==   !=Comparison equal to/Comparison not equal toLeft to Right
&Bitwise ANDLeft to Right
^Bitwise XORLeft to Right
|Bitwise ORLeft to Right
&&Logical ANDLeft to Right
||Logical ORLeft to Right
?:Ternary Conditional OperatorRight to Left
=
*=    /=   %=
+=    -=
<<=   >>=
&=    ^=
|=
Assignment Operator
Mulplication/division/modulo assignment
Addition/Subtraction assignment
Bitwise left shift/right shift assignment
Bitwise AND/XOR assignment
Bitwise OR assignment


Right to Left
,Comma OperatorLeft to Right

No comments:

Post a Comment