In the C statement a = b = c = 4;, why do all three variables receive the value 4?
Correct answer B. Assignment associates right to left, so c = 4 is evaluated first and its value is assigned onward
Explanation
Assignment operators group right to left, so the statement parses as a = (b = (c = 4)). An assignment expression has the value of the left operand after assignment, so c = 4 yields 4, which is then assigned to b and then to a. Left-to-right grouping would mean (a = b) = c, which is invalid because an assignment expression is not an lvalue in C.
Answer checked How we write and check questions
Discussion