Operator Precedence
The precedence of an operator specifies how it binds two expressions together.
For example, in the expression 7 + 4 * 2, the answer is 15 and not 22 because the multiplication ("*") operator has a higher precedence than the addition ("+") operator.
| 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 |
|