Order of Operations in C

(Last Mod: 27 November 2010 21:38:37 )

ECE-1021 Home


LEVEL Description Operator Associativity
1 Grouping Parens ( ) left
Function Expression ( )
Array Expression [ ]
struct indirection ->
struct member .
2 Increment / Decrement ++ -- right
Bitwise invert (1's complement) ~
Logical NOT (unary NOT) !
Address &
Dereference *
Cast ( type )
Unary plus (positive sign) +
Unary minus (negative sign) -
Size in bytes sizeof
3 Multiplication * left
Division /
Modulus %
4 Addition +
Subtraction -
5 Shift Left <<
Shift Right >>
6 Less than <
Less than or equal <=
Greater than >
Greater than or equal >=
7 Equal ==
Not equal !=
8 Bitwise AND &
9 Bitwise XOR ^
10 Bitwise OR |
11 Logical AND &&
12 Logical OR ||
13 Conditional ? : right
14 Assignment

=

*=  /=  %=

+=  -=

>>=  <<=

&=  |=  ^=

15 Comma , left