About Lesson
Following table summarises the precedence and associativity rules of all the operators in C.
Operators | Associativity |
---|---|
() [] -> . | left to right |
! ~ ++ -- + - * & (type) sizeof | right to left |
* / % | left to right |
+ - | left to right |
<< >> | left to right |
< <= > >= | left to right |
== != | left to right |
& | left to right |
^ | left to right |
| | left to right |
&& | left to right |
|| | left to right |
? : | right to left |
= += -= *= /= %= &= ^= |= <<= >>= | right to left |
, | left to right |
Operators in the same row have same precedence. Precedence decreases from top to bottom in the table.
In the first row, the operator () refers to a function call. The operators -> and . are used to access members of structures.
In the second row, sizeof operator gives size of an object. * is indirection through a pointer and & is address of an object.
We’ll go through these operators in details in subsequent lessons.