The following is a table that lists the precedence and associativity of all the operators in the C languages.

Operators are listed top to bottom, in descending precedence. Descending precedence refers to the priority of evaluation. Considering an expression, an operator which is listed on some row will be evaluated prior to any operator that is listed on a row further below it. Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same precedence, in the given direction.

PrecedenceOperatorDescriptionAssociativity
2 ++ Postfix increment Left-to-right
-- Postfix decrement
() Function call
[] Array subscripting
. Element selection by reference
-> Element selection through pointer
3 ++ Prefix increment Right-to-left
-- Prefix decrement
+ Unary plus
- Unary minus
! Logical NOT
(type) Type cast
* Indirection (dereference)
& Address-of
sizeof Size-of
5 * Multiplication Left-to-right
/ Division
% Modulo (remainder)
6 + Addition Left-to-right
- Subtraction
8 < Less than Left-to-right
<= Less than or equal to
> Greater than
>= Greater than or equal to
9 == Equal to Left-to-right
!= Not equal to
13 && Logical AND Left-to-right
14 || Logical OR Left-to-right
15 ?: Ternary conditional (see ?:) Right-to-left
16 = Direct assignment Right-to-left
+= Assignment by sum
-= Assignment by difference
*= Assignment by product
/= Assignment by quotient
%= Assignment by remainder
18

lowest

, Comma Left-to-right

Note

You have no rights to post comments