C Operator Precedence Table

Complete reference for C operator precedence and associativity with examples

Understanding Operator Precedence

Operator precedence determines the order in which operators are evaluated in expressions. Higher precedence (lower numbers) operators are evaluated first. When operators have the same precedence, associativity determines the evaluation order.

Precedence
OperatorsDescriptionAssociativityExamples
1
()[]->.

Postfix expressions, function calls, array subscripts, member access

postfix
Left-to-right
func()arr[0]
2
++--+-!~(type)*&sizeof

Unary operators, prefix increment/decrement, type casting

unary
Right-to-left
++x--y
3
*/%

Multiplicative operators

arithmetic
Left-to-right
a * bx / y
4
+-

Additive operators

arithmetic
Left-to-right
a + bx - y
5
<<>>

Bitwise shift operators

bitwise
Left-to-right
x << 2y >> 1
6
<<=>>=

Relational operators

relational
Left-to-right
a < bx <= y
7
==!=

Equality operators

relational
Left-to-right
a == bx != y
8
&

Bitwise AND

bitwise
Left-to-right
a & b
9
^

Bitwise XOR

bitwise
Left-to-right
a ^ b
10
|

Bitwise OR

bitwise
Left-to-right
a | b
11
&&

Logical AND

logical
Left-to-right
a && b
12
||

Logical OR

logical
Left-to-right
a || b
13
?:

Ternary conditional operator

conditional
Right-to-left
condition ? true_val : false_val
14
=+=-=*=/=%=&=|=^=<<=>>=

Assignment operators

assignment
Right-to-left
a = bx += 5
15
,

Comma operator

comma
Left-to-right
a = 1, b = 2