Swanson Technologies

C Language Operator Precedence Chart

Operator precedence describes the order in which C reads expressions. For example, the expression a=4+b*2 contains two operations, an addition and a multiplication. Does the C compiler evaluate 4+b first, then multiply the result by 2, or does it evaluate b*2 first, then add 4 to the result? The operator precedence chart contains the answers. Operators higher in the chart have a higher precedence, meaning that the C compiler evaluates them first. Operators on the same line in the chart have the same precedence, and the "Associativity" column on the right gives their evaluation order.

Operator Precedence Chart
Operator Type Operator Associativity
Primary Expression Operators () [] . -> expr++ expr-- left-to-right
Unary Operators * & + - ! ~ ++expr --expr (typecast) sizeof right-to-left
Binary Operators * / % left-to-right
+ -
>> <<
< > <= >=
== !=
&
^
|
&&
||
Ternary Operator ?: right-to-left
Assignment Operators = += -= *= /= %= >>= <<= &= ^= |= right-to-left
Comma , left-to-right