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.

Get Practical C Programming, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.