What does the program print to the monitor?
The variable contains: 123
This program printed out the same thing as the first example program. However, this program did not initialize the variable and so had to put a value into it later.
Assignment statements look like this:
variableName = expression ;
=
is the assignment operator.In the source file, the statement that declares a variable must occur before any assignment statement that uses that variable.
Is the following correct (assume that sum
has already been correctly declared):
sum = 42 - 12 ;