Precedence:
In C every operator has special precedence which is
associated with it.The order in which different types of operators in an
expression are evaluated is known as operator precedence. The operators which
has higher precedence are executed first and operators which has lower
precedence are executed later.
Example:
c = 25-{(5*4)/2} -10+4
c = 25-(20/2) - 10+4
c = 25-10-10+4
c = 15-10+4
c = 5+4
c = 9
Example:
c = 25-{(5*4)/2} -10+4
c = 25-(20/2) - 10+4
c = 25-10-10+4
c = 15-10+4
c = 5+4
c = 9
Associativity:
The order in which operators of same precedence are evaluated is known as operator associativity. Operators which has same precedence level is evaluated from left to right.
Example:
The order in which operators of same precedence are evaluated is known as operator associativity. Operators which has same precedence level is evaluated from left to right.
Example:


No comments:
Post a Comment