C Programming - Expressions - Discussion

Discussion Forum : Expressions - True / False Questions (Q.No. 3)
3.
In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators
True
False
Answer: Option
Explanation:

The equal to = operator has Right-to-Left Associativity. So it assigns b=5 then a=b.

Discussion:
3 comments Page 1 of 1.

Swagath said:   1 decade ago
@Megha

Suppose, int b=5, a;

a=b; (it's correct way of assigning of a value of 'a'. b is already assigned)
then a value will be same as b i.e. 5.

Now come a=b=5. if you take a=b as first. The variables a and b are not assigned to any value and remember that no two variables are assigned to each other without assign a value.

Kumar said:   1 decade ago
No, equal to operator has right to left associativity
a=b=5;
b=5;
a=5;

Megha said:   1 decade ago
How is this possible?

Post your comments here:

Your comments will be displayed after verification.