3.7. ExpressionsStatements that evaluate to a value are called expressions . You may be surprised how many statements do evaluate to a value. For example, an assignment such as: myVariable = 57; is an expression; it evaluates to the value assignedin this case, 57.
Because myVariable = 57 is an expression that evaluates to 57, it can be used as part of another assignment, such as: mySecondVariable = myVariable = 57; What happens in this statement is that the literal value 57 is assigned to the variable myVariable . The value of that assignment (57) is then assigned to the second variable, mySecondVariable . Thus, the value 57 is assigned to both variables. You can assign a value to any number of variables with one statement using the assignment operator ( = ), as in the following: int a,b,c,d,e; a = b = c = d = e = 20; |