C Operator Precedence

Type any C expression:




Unsupported expressions:

The C precedence order is as follows, from first to last evaluated:

Tokens Operator Class Association
names, literals simple tokens primary n/a
a[k] subscripting postfix left-to-right
f(…) function call postfix left-to-right
.
direct selection postfix left-to-right
->
indirect selection postfix left-to-right
++ --
increment, decrement postfix left-to-right
(
typename
){
init
}
compound literal (C99) postfix left-to-right
++ --
increment, decrement prefix right-to-left
sizeof
size unary right-to-left
~
bitwise not unary right-to-left
!
logical not unary right-to-left
- +
arithmetic negation, plus unary right-to-left
&
address of unary right-to-left
*
indirection unary right-to-left
(
typename
)
casts unary right-to-left
* / %
multiplicative binary left-to-right
+ -
additive binary left-to-right
<< >>
shift binary left-to-right
< <= > >=
relational binary left-to-right
== !=
equality binary left-to-right
&
bitwise and binary left-to-right
^
bitwise exclusive-or binary left-to-right
|
bitwise or binary left-to-right
&&
logical and binary left-to-right
||
logical or binary left-to-right
? :
conditional ternary right-to-left
= += -= *=
/= %= <<= >>=
&= ^= |=
assignment binary right-to-left
,
sequential evaluation binary left-to-right

References

© 2024 Mats Mattsson