Precedence |
|
Associativity |
|---|---|---|
15 |
( ) [ ] -> . |
L to R |
14 |
! ~ ++ -- + - * & (type) sizeof |
R to L |
13 |
* / % |
L to R |
12 |
+ - |
L to R |
11 |
<< >> |
L to R |
10 |
< <= >= > |
L to R |
9 |
== != |
L to R |
8 |
& |
L to R |
7 |
^ |
L to R |
6 |
| |
L to R |
5 |
&& |
L to R |
4 |
|| |
L to R |
3 |
?: |
R to L |
2 |
= += -= *= /= %= ^= |= <<= >>= |
R to L |
1 |
, |
L to R |
Operations of higher priority are evaluated before those of lower priority
When adjacent operations have equal priority, grouping rules must be observed. Most operators group from left ro right so:
a = b + c + d;
is equivalent to ...
a = (b + c) + d;
but
p = q = r = s;
is equivalent to ...
p = (q = (r = s));