Operator Precedence Rules - Other Language Features - Practical C Programming, 3rd Edition (2011)

Practical C Programming, 3rd Edition (2011)

Part IV. Other Language Features

Appendix C. Operator Precedence Rules

Standard Rules

Operators listed in Table C-1 near the top are evaluated before those below.

Table C-1. C Precedence Rules

Precedence

Operator

1.

( )

[ ]

->

.

2.

!

~

++

(type)

- (unary)

* (dereference)

& (address of)

sizeof

3.

* (multiply)

/

%

4.

+

-

5.

<<

>>

6.

<

<=

>

>=

7.

==

!=

8.

& (bitwise and)

9.

^

10.

|

11.

&&

12.

||

13.

?:

14.

=

+=

-=

etc.

15.

,

Practical Subset

Table C-2. Precedence Rules, Practical Subset

Precedence

Operator

1.

* (multiply)

/

%

2.

+

-

Put parentheses around everything else.