Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

1/2/2015

COperatorPrecedenceTable

difranco.net

COperatorPrecedenceTable
ThispagelistsCoperatorsinorderofprecedence(highesttolowest).Theirassociativityindicatesinwhatorderoperatorsof
equalprecedenceinanexpressionareapplied.
Operator

Description

Associativity

()
[]
.
>
++

Parentheses(functioncall)(seeNote1)
Brackets(arraysubscript)
Memberselectionviaobjectname
Memberselectionviapointer
Postfixincrement/decrement(seeNote2)

lefttoright

++
+
!~
(type)
*
&
sizeof

Prefixincrement/decrement
Unaryplus/minus
Logicalnegation/bitwisecomplement
Cast(convertvaluetotemporaryvalueoftype)
Dereference
Address(ofoperand)
Determinesizeinbytesonthisimplementation

righttoleft

*/%

Multiplication/division/modulus

lefttoright

Addition/subtraction

lefttoright

Bitwiseshiftleft,Bitwiseshiftright

lefttoright

<<=
>>=

Relationallessthan/lessthanorequalto
Relationalgreaterthan/greaterthanorequalto

lefttoright

==!=

+
<<>>

Relationalisequalto/isnotequalto

lefttoright

&

BitwiseAND

lefttoright

BitwiseexclusiveOR

lefttoright

BitwiseinclusiveOR

lefttoright

LogicalAND

lefttoright

||

LogicalOR

lefttoright

?:

Ternaryconditional

righttoleft

Assignment
Addition/subtractionassignment
Multiplication/divisionassignment
Modulus/bitwiseANDassignment
Bitwiseexclusive/inclusiveORassignment
Bitwiseshiftleft/rightassignment

righttoleft

Comma(separateexpressions)

lefttoright

&&

=
+==
*=/=
%=&=
^=|=
<<=>>=
,
Note1:

Parenthesesarealsousedtogroupsubexpressionstoforceadifferentprecedencesuch
parentheticalexpressionscanbenestedandareevaluatedfrominnertoouter.
Note2:

Postfixincrement/decrementhavehighprecedence,buttheactualincrementordecrementof
theoperandisdelayed(tobeaccomplishedsometimebeforethestatementcompletes
execution).Sointhestatementy=x*z++thecurrentvalueofzisusedtoevaluatethe
expression(i.e.,z++evaluatestoz)andzonlyincrementedafterallelseisdone.Seepostinc.c
foranotherexample.

Updated:20111216

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

1/1

You might also like