Expression evaluation
#In c language expression evaluation is mainly depends on priority and associativity.
Priority
This represents the evaluation of expression starts from "what" operator.
Associativity
It represents which operator should be evaluated first if an expression is containing more than one operator with same priority.
Operator | Priority | Associativity |
---|---|---|
{}, (), [] | 1 | Left to right |
++, --, ! | 2 | Right to left |
*, /, % | 3 | Left to right |
+, - | 4 | Left to right |
<, <=, >, >=, ==, != | 5 | Left to right |
&& | 6 | Left to right |
|| | 7 | Left to right |
?: | 8 | Right to left |
=, +=, -=, *=, /=, %= | 9 | Right to left |