Operator precedence

The precedence of C language operators.

Priority Operator Grammar Name Join Direction
1 () x (y) Function call operator Left
[] x [y] Subscript operator Left
. x. y . Operator (dot operator) left
-> x->y->operator(arrow operator) left
++ x ++ Post-increment operator Left
- y- Post-decrease operator Left
2 ++ ++ x Prefix increment operator right
--y Prefix subtraction operator right
sizeof sizeof x sizeof operator right
& & x unary & operator (address operator) right
* * x unary * operator (indirect operator) right
+ + x unary + operator right
- -x unary-operator right
~ ~ x ~ operator (complement operator) right
! ! x logical negation operator right
3 () (x) y Cast operator right
4 * x * y Binary * operator left
/ x / y / operator left
% x%y %operator left
5 + x + y Binary + operator left
- x-y Binary-operator left
6 <<<< td> x << y << operator left
>> x >> y >> operator left
7 << td> x left
<= x <= y <= operator left
> x> y > operator left
> = x> = y > = operator left
8 == x == y == operator left
! = x! = y ! = Operator left
9 & x & y Bitwise and operator left
10 ^ x ^ y Bitwise exclusive or operator left
11 | x | y Bitwise or operator Left
12 && x && y logical and operator left
13 || x || y logical or operator left
14 ?: x? y: z conditional operator right
15 = x = y Simple assignment operator right
+ =-= * = / =%= << = >> = & = ^ = | = x + = y Composite assignment operator right
16 , x, y Comma operator left

Associated Information