What is meant by right-associative ? Elaborate it using an example.
Associativity:
The associativity is the property that determines how the operator of the same precedence is executed if the parentheses are missing in the expression.
The evaluation order of the expression is determined by precedence and associativity if the parentheses are missing in the expression.
The associativity can be:
The right-associative means the operators are grouped from the right.
For example:
The assignment operator '=' is right-associative in most of the programming languages.
a = b = c
First, the value of c is assigned to b and then assign to variable
a.
The operator '^' is right-associative.
x = 2^3^2
The above expression will be calculated as:
x = 2^(3^2)
x = 2^(9)
x = 512
Get Answers For Free
Most questions answered within 1 hours.