0% found this document useful (0 votes)
138 views1 page

C Operator Precedence and Associativity

The document describes the operator precedence and associativity in C. It lists the operators from highest to lowest precedence and whether the associativity is left-to-right or right-to-left. Parentheses, function calls, and member selection have the highest precedence, while assignment operators have the lowest precedence.

Uploaded by

Sahil Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views1 page

C Operator Precedence and Associativity

The document describes the operator precedence and associativity in C. It lists the operators from highest to lowest precedence and whether the associativity is left-to-right or right-to-left. Parentheses, function calls, and member selection have the highest precedence, while assignment operators have the lowest precedence.

Uploaded by

Sahil Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

C Operator Precedence and Associativity

Operator Description Associativity


()
[]
.
->
++ --
Parentheses (function call) (see Note 1)
Brackets (array subscript)
Member selection via object name
Member selection via pointer
Postfix increment/decrement
left-to-right
++ --
+ -
! ~
(type)
*
&
sizeof
Prefix increment/decrement
Unary plus/minus
Logical negation/bitwise complement
Cast (change type)
Dereference
Address
Determine size in bytes
right-to-left
* / % Multiplication/division/modulus left-to-right
+ - Addition/subtraction left-to-right
<< >> Bitwise shift left, Bitwise shift right left-to-right
< <=
> >=
Relational less than/less than or equal to
Relational greater than/greater than or equal to
left-to-right
== != Relational is equal to/is not equal to left-to-right
& Bitwise AND left-to-right
^ Bitwise exclusive OR left-to-right
| Bitwise inclusive OR left-to-right
&& Logical AND left-to-right
|| Logical OR left-to-right
?: Ternary conditional right-to-left
=
+= -=
*= /=
%= &=
^= |=
<<= >>=
Assignment
Addition/subtraction assignment
Multiplication/division assignment
Modulus/bitwise AND assignment
Bitwise exclusive/inclusive OR assignment
Bitwise shift left/right assignment
right-to-left
, Comma (separate expressions) left-to-right
Note 1: Parentheses are also used to group expressions to force a different order of evaluation;
such parenthetical expressions can be nested and are evaluated from inner to outer.

You might also like