Module: Arithmetic expressions


Problem

1/5

assignment operator

Theory Click to read/hide

Assignment operator 
We already know that you can set the value of any variable using the input operator.  An input statement is used in cases where a value is specified by the user during program execution.
But, very often we need to set a new value for a variable by calculating it using a certain formula. In this case, the - assignment operator will help us. We have already used it a little in recent problems. Now let's talk about it in more detail.
 
The general form of an assignment operator is as follows: <variable name> = <expression>;

The assignment operator works like this:
1. First, the expression to the right of the assignment sign is evaluated.
2. The resulting value of the expression is stored (say "assigned") in the variable to the left of the assignment sign. In this case, the old value of the variable is erased.

For example, if we need to set the value of the c variable to twice the value of the b variable, then we will need to write it like this: c = 2 * b; Do not forget that in programming you cannot omit multiplication signs in an expression. Otherwise, the computer will not understand what you want to multiply.
For example, you can't just write c = 2b, that would be wrong!

Problem

On the 6th line, write an assignment operator, as a result of which the variable c will take the value of the sum of the variables a and b.