Precedence and associativity in C

If more than operators are involved in an expression, C has a predefined rule of priority for the operators. The rule of priority of operators are called precedence.

If more than one operators of the same precedence(priority), is present in an expression, then the order on which they execute is called the associativity.

The details of the precedence and associativity can be shown in the following table.

OperatorDescriptionAssociativityRank(precedence)
()
[]
Function call
Array Element Reference
Left to Right1
+

++

!
~
*
&
sizeof
(type)
Unary plus
Unary Minus
Increment
Decrement
Logical Negation
One’s complement
Pointer reference (indirection)
Address
Size of an object
Type cast (conversion)
Right to Left2
*
/
%
Multiplication
Division
Modulus
Left to Right3
+
Addition (Binary Plus)
Substraction (Binary Minus)
Left to Right4
<<
>>
Left shift
Right shift
Left to Right5
<
<=
>
>=
Less than
Less than or equal to
Greater than
Greater than or equal to
Left to Right6
==
!=
Equality
Inequality
Left to Right7
&Bit-wise ANDLeft to Right8
^Bit-wise XORLeft to Right9
|Bit-wise ORLeft to Right10
&&Logical ANDLeft to Right11
||Logical ORLeft to Right12
?:Condiitional OperatorLeft to Right13
=, *=, /=, %=, +=
-=, &=, ^=, |=,
>>=, <<=
Assignment OperatorRight to Left14
,Comma OperatorLeft to Right15
Precedence and Associativity in C