multi variable assignment cpp
Sure! Here is an example of multi-variable assignment in C++:
int a, b, c;
a = 10;
b = 20;
c = a + b;
Explanation:
Variable declaration: In the first line, we declare three variables
a
,b
, andc
of typeint
(integer). This means that these variables can hold integer values.Variable assignment: In the next three lines, we assign values to the variables
a
andb
. We assign the value10
toa
and the value20
tob
. The=
symbol is used to assign a value to a variable.Expression evaluation: In the fourth line, we perform an addition operation using the variables
a
andb
. The result of the addition operation (a + b
) is then assigned to the variablec
.
At the end of this code snippet, the variables a
, b
, and c
will have the following values:
- a
will have the value 10
- b
will have the value 20
- c
will have the value 30
This is a simple example of multi-variable assignment in C++. Let me know if you have any further questions.