What does the program print to the monitor?
Answer:
The variable contains: 123
Assignment Statement Syntax
This program prints 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 ;
- The equal sign
=is the assignment operator. - variableName is the name of a variable that has been declared previously in the program.
- expression is a collection of characters that calls for a value.
Here are some example assignment statements (assume that the variables have already been declared):
total = 3 + 5; price = 34.56; tax = total*0.05;
In the source file, the variable must be declared before any assignment statement that uses that variable.
QUESTION 11:
Is the following correct:
int sum; sum = 42 - 12 ;