C Operator Precedence and Associativity
Operator Description Associativity
() Parentheses (function call) (see Note 1) lefttoright
[] Brackets (array subscript)
. Member selection via object name
-> Member selection via pointer
++ -- Postfix increment/decrement
++ -- Prefix increment/decrement righttoleft
+ - Unary plus/minus
! ~ Logical negation/bitwise complement
(type) Cast (change type)
* Dereference
& Address
sizeof Determine size in bytes
* / % Multiplication/division/modulus lefttoright
+ - Addition/subtraction lefttoright
<< >> Bitwise shift left, Bitwise shift right lefttoright
< <= Relational less than/less than or equal to lefttoright
> >= Relational greater than/greater than or equal to
== != Relational is equal to/is not equal to lefttoright
& Bitwise AND lefttoright
^ Bitwise exclusive OR lefttoright
| Bitwise inclusive OR lefttoright
&& Logical AND lefttoright
|| Logical OR lefttoright
?: Ternary conditional righttoleft
= Assignment righttoleft
+= -= Addition/subtraction assignment
*= /= Multiplication/division assignment
%= &= Modulus/bitwise AND assignment
^= |= Bitwise exclusive/inclusive OR assignment
<<= >>= Bitwise shift left/right assignment
, Comma (separate expressions) lefttoright
Note 1: Parentheses are also used to group expressions to force a different order of evaluation;
such parenthetical expressions can be nested and are evaluated from inner to outer.