Precedence of Operators

Previous Operators and Punctuators Next

In the following table of operator precedence, the C operators are divided into 15 categories. The #1 category has the highest precedence; category #2 (Unary operators) takes second precedence, and so on to the Comma operator, which has lowest precedence. The operators within each category have equal precedence.

The Unary (category #2), Conditional (category #13), and Assignment (category #14) operators associate right-to-left; all other operators associate left-to-right.

CategoryOperatorWhat it is (or does)
1. Highest [ ]
( )
->
.
Array subscript
Function call
Indirect component selector
Direct component selector
2. Unary !
~
+
-
++
--
&
*
sizeof
(type)
Logical negation (NOT)
Bitwise (1's) complement
Unary plus
Unary minus
Preincrement or postincrement
Predecrement or postdecrement
Address
Indirection
Size of operand, in bytes
TypeCast
3. Multiplicative *
/
%
Multiply
Divide
Remainder (modulus)
4. Aditive +
-
Binary plus
Binary minus
5. Shift <<
>>
Shift left
Shift right
6. Relational <
<=
>
>=
Less than
Less than or equal to
Greater than
Greater than or equal to
7. Equality ==
!=
Equal to
Not equal to
8. & Bitwise AND
9. ^ Bitwise XOR
10. | Bitwise OR
11. && Logical AND
12. || Logical OR
13. Conditional ? : "a ? x : y" means "if a then x, else y"
14. Assignment =
*=
/=
%=
+=
-=
&=
^=
|=
<<=
>>=
Simple assignment
Assign product
Assign quotient
Assign remainder (modulus)
Assign sum
Assign difference
Assign bitwise AND
Assign bitwise XOR
Assign bitwise OR
Assign left shift
Assign right shift
15. Comma , Evaluate