We have learned how to combine expressions to make compound expressions. We can also do this with assignments. For example, we could initialize variables as follows:
int height, width, length;
height = width = length = 0;
The expressions are evaluated from right to left, and the final result of the expression is the value of the last assignment. Each variable is assigned a value of 0.
Another way to put multiple assignments in a single statement is to use the ,sequence operator. We could write a simple swap statement in one line with three variables, as follows:
int first, second, temp;
// Swap first & second variables.
temp = first, first = second, second = temp;
The sequence of three assignments is performed from left to right. This would be equivalent to the following three statements:
temp = first;
first = second;
second = temp;
Either way is correct. Some might argue that the...