what is the associative property of an operator code example
Example: what is the associative property of an operator
Left Associative means we evaluate our expression from left to right
Right Associative means we evaluate our expression from right to left
We know *, /, and % have same precedence, but as per associativity, answer may change:
For eg: We have expression: 4 * 8 / 2 % 5
Left associative: (4 * 8) / 2 % 5 ==> (32 / 2) % 5 ==> 16 % 5 ==> 1
Right associative: 4 * 8 /(2 % 5) ==> 4 * ( 8 / 2) ==> 4 * 4 ==> 16