Friday, July 27, 2012

Precedence and associativity in c

Precedence: Precedence is used to determine the order in which different operators in complex expression are evaluated.

Assiciativity: Associativity is used to determine the order in which  operators with the same precedence are evaluated in a complex expression. It can be a left to right or right to left depends on the expression.

Left to right associativity: 3*8/4%4*5
Right to left associativity: Several operators have right to left associativity. for example when more than one assignment operator occur in an expression e.g a+=b*=c-=5 evaluated as (a+=(b*=(c-=5))).


4 comments: