C OPERATORS PRECEDENCE AND ASSOCIATIVITY

Rank

Operator

Explanation

Associativity

1

()

[]

.

->

Parenthesis

Square brackets

Direct Member selection

Indirect Member selection

 

Left to right

2

++

--

!

~

(type)

&

*

Increment

Decrement

Logical negation

Bitwise complement

Type casting

Address

Pointer reference

Right to left

3

*

/

%

Multiplication

Division

Remainder

Left to right

4

+

-

Addition

Subtraction

Left to right

5

<< 

>> 

Left shift

Right shift

Left to right

6

< 

<=

> 

>=

Less than

Less than or equal to

Greater than

Greater than or equal to

Left to right

7

==

!=

Equal to

Not equal to

Left to right

8

&

 

Bitwise AND

 

Left to right

9

^

 

Bitwise exclusive OR

 

Left to right

10

|

Bitwise Inclusive OR

Left to right

11

&&

Logical AND

Left to right

12

||

Logical OR

Left to right

13

?:

Ternary operator

Right to Left

14

=

*=

/=

%=

+=

-=

&=

^=

|=

<<=

>>=

Assignment

Multiplication assignment

Division assignment

Modulus assignment

Addition assignment

Subtraction assignment

Bitwise And assignment

Bitwise inclusive assignment

Bitwise exclusive assignment

Bitwise shift left assignment

Bitwise shift right assignment

Right to left

15

,

Comma

Left to right

 

1 comment: