What does the following assignment statement statement do:
sum = 42 - 12 ;
It: (1) evaluates the expression, which yields 30; then (2) puts that
value in the variable sum
.
Normally you would say:
The statement puts 30 into sum
.
However, you must understand that two steps take place, in order. When the expression on the right gets complicated you need to know the two steps to figure out what happens.
An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.
This (slighly incomplete) definition needs some explanation:
This might sound awful. Actually, this is stuff that you know from algebra, like:
(32 - y) / ( x + 5 )
In the above, the character "/" means "division." Not just any mess will work (of course). The following:
32 - y) / ( x 5 + )
is not a syntactically correct expression. There are rules for this, but the best rule is that an expression must look OK as algebra.