“Operators” are symbols (both single characters and character combinations) that specify how values are to be manipulated. Each symbol is interpreted as a single unit, called a token. See topic for information on tokens.
Table 1.5 gives the precedence order for the C operators. For a complete description and the ANSI grammar for each operator, see “Operators”.
Table 1.5 Precedence and Associativity of C Operators
Symbol 1 | Type of Operation | Associativity |
[ ] ( ) . –> postfix ++ and postfix –– :> | Expression, Left to right | |
Prefix ++ and prefix –– sizeof & * + – ~ ! | Unary | Right to left |
typecasts | Unary | Right to left |
* / % | Multiplicative | Left to right |
+ – | Additive | Left to right |
<< >> | Bitwise shift | Left to right |
< > <= >= | Relational | Left to right |
== != | Equality | Left to right |
& | Bitwise AND | Left to right |
^ | Bitwise-exclusive OR | Left to right |
| | Bitwise-inclusive OR | Left to right |
&& | Logical-AND | Left to right |
|| | Logical-OR | Left to right |
? : | Conditional | Right to left |
= *= /= %= += –= <<= >>= &= |= ^= | Simple and compound assignment2 | Right to left |
, | Sequential evaluation | Left to right |
1 Operators are listed in descending order of precedence. If several operators appear in the same line or in a group, they have equal precedence.
2 All simple- and compound-assignment operators have equal precedence.