We already know that you can set the value of a variable using the input staememt.
The input statement is used in cases where the value is set by the user during program execution.
But very often we need to set a new value for a variable, calculating it according to a certain formula. In this case, the assignment expression
will help us
The general form of the assignment expression is as follows:
<variable>=<expression>;
The assignment expression works as follows:
1. First, the expression to the right of the assignment sign is calculated
2. The received value of the expression is saved (they say "assigned") in the variable standing 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 variable c to a value two times the value of the variable b, then we will have to write it like this:
с=2*b;
Remember that in programming you cannot omit the multiplication signs in an expression. Otherwise, the computer does not understand what you want to multiply.
For example, you can’t just write
c=2b, it will be wrong!