# What is Operator Precedence?

Operator precedence is used to determine the order of operators evaluated in an expression. In c programming language every operator has precedence (priority). When there is more than one operator in an expression the operator with higher precedence is evaluated first and the operator with least precedence is evaluated last.

# What is Operator Associativity?

Operator associativity is used to determine the order of operators with equal precedence evaluated in an expression. In c programming language, when an expression contains multiple operators with equal precedence, we use associativity to determine the order of evaluation of those operators.

In c programming language the operator precedence and associativity is as shown in the following table...

 Precedence Operator Operator Meaning Associativity 1 ()[]->. function callarray referencestructure member accessstructure member access Left to Right 2 !~+-++--&*sizeof(type) negation1's complementUnary plusUnary minusincrement operatordecrement operatoraddress of operatorpointerreturns size of a variabletype conversion Right to Left 3 */% multiplicationdivisionremainder Left to Right 4 +- additionsubtraction Left to Right 5 <<>> left shiftright shift Left to Right 6 <<=>>= less thanless than or equal togreater thangreater than or equal to Left to Right 7 ==!= equal tonot equal to Left to Right 8 & bitwise AND Left to Right 9 ^ bitwise EXCLUSIVE OR Left to Right 10 | bitwise OR Left to Right 11 && logical AND Left to Right 12 || logical OR Left to Right 13 ?: conditional operator Left to Right 14 =*=/=%=+=-=&=^=|=<<=>>= assignmentassign multiplicationassign divisionassign remainderassign additonassign subtractionassign bitwise ANDassign bitwise XORassign bitwise ORassign left shiftassign right shift Right to Left 15 , separator Left to Right

In the above table, the operator precedence decrese from top to bottom and increase from bottom to top.