0% found this document useful (0 votes)
229 views

C Operator Precedence Table

This document provides a table listing C operators in order of precedence from highest to lowest. It includes the operator, a description, and whether the operator is left-associative or right-associative. Parentheses, array subscripting, and member selection have the highest precedence. Assignment operators have the lowest precedence. Notes explain that parentheses can be used to alter precedence and that postfix increment/decrement operators are evaluated before incrementing/decrementing the operand.

Uploaded by

Prakhar Khare
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
229 views

C Operator Precedence Table

This document provides a table listing C operators in order of precedence from highest to lowest. It includes the operator, a description, and whether the operator is left-associative or right-associative. Parentheses, array subscripting, and member selection have the highest precedence. Assignment operators have the lowest precedence. Notes explain that parentheses can be used to alter precedence and that postfix increment/decrement operators are evaluated before incrementing/decrementing the operand.

Uploaded by

Prakhar Khare
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

4/21/2018 C Operator Precedence Table

difranco.net

C Operator Precedence Table


This page lists C operators in order of precedence (highest to lowest). Their associativity indicates in what order operators of
equal precedence in an expression are applied.

Operator Description Associativity


() Parentheses (function call) (see Note 1) left-to-right
[] Brackets (array subscript)
. Member selection via object name
-> Member selection via pointer
++ -- Postfix increment/decrement (see Note 2)
++ -- Prefix increment/decrement right-to-left
+- Unary plus/minus
!~ Logical negation/bitwise complement
(type) Cast (convert value to temporary value of type)
* Dereference
& Address (of operand)
sizeof Determine size in bytes on this implementation
* / % 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 left-to-right
> >= Relational greater than/greater than or equal to
== != 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 right-to-left
+= -= Addition/subtraction assignment
*= /= Multiplication/division assignment
%= &= Modulus/bitwise AND assignment
^= |= Bitwise exclusive/inclusive OR assignment
<<= >>= Bitwise shift left/right assignment
, Comma (separate expressions) left-to-right

Note 1:
Parentheses are also used to group sub-expressions to force a different precedence; such
parenthetical expressions can be nested and are evaluated from inner to outer.
Note 2:
Postfix increment/decrement have high precedence, but the actual increment or decrement of
the operand is delayed (to be accomplished sometime before the statement completes
execution). So in the statement y = x * z++; the current value of z is used to evaluate the
expression (i.e., z++ evaluates to z) and z only incremented after all else is done. See postinc.c
for another example.

Updated: 20111216

http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm 1/1

You might also like