Precedence

The full precedence of operators is shown in the table. Note carefully that the effects of apparently simple comparisons may require parentheses to avoid becoming confusing, especially as C will treat any integer as a candidate for a logical operation.

Consider the following.

         3  > 4 && 2 < 5
is legal, but perhaps ambiguous
         (3 > 4) && (2 < 5)
is arguably clearer.

Full precedence for operators
1st
()[]-> . dot
2nd
++!--(type) ~+ unary - unary* dereference & address
3rd
*/%
4th
+-
5th
<<>>
6th
>>=<<=
7th
==!=
8th
&
9th
^
10th
|
11th
&&
12th
||
13th
?:
14th
=+=-=*=etc.
15th
,


Next - statements.

Back to expressions.

Back to Contents page.