This document describes C operator precedence and associativity. It lists C operators from highest to lowest precedence and whether they associate left-to-right or right-to-left. Parentheses have the highest precedence and associate left-to-right, while assignment operators have the lowest precedence and associate right-to-left.
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 ratings0% found this document useful (0 votes)
59 views1 page
Precedence PDF
This document describes C operator precedence and associativity. It lists C operators from highest to lowest precedence and whether they associate left-to-right or right-to-left. Parentheses have the highest precedence and associate left-to-right, while assignment operators have the lowest precedence and associate right-to-left.
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) lefttoright [] Brackets (array subscript) . Member selection via object name -> Member selection via pointer ++ -- Postfix increment/decrement ++ -- Prefix increment/decrement righttoleft + - Unary plus/minus ! ~ Logical negation/bitwise complement (type) Cast (change type) * Dereference & Address sizeof Determine size in bytes * / % Multiplication/division/modulus lefttoright + - Addition/subtraction lefttoright << >> Bitwise shift left, Bitwise shift right lefttoright < <= Relational less than/less than or equal to lefttoright > >= Relational greater than/greater than or equal to == != Relational is equal to/is not equal to lefttoright & Bitwise AND lefttoright ^ Bitwise exclusive OR lefttoright | Bitwise inclusive OR lefttoright && Logical AND lefttoright || Logical OR lefttoright ?: Ternary conditional righttoleft = Assignment righttoleft += -= Addition/subtraction assignment *= /= Multiplication/division assignment %= &= Modulus/bitwise AND assignment ^= |= Bitwise exclusive/inclusive OR assignment <<= >>= Bitwise shift left/right assignment , Comma (separate expressions) lefttoright
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.