After we declare a variable, we can give it a value!
Suppose that we have declared an
int variable called
score, to set it to 0, we can simply write:
score = 0;
scoreis the name of the variable.
0is the value you want to store inside the variable.
Note: In C++, a single equal sign
= does not really mean “equal”. It means “assign”. In the code above, we are assigning the
score variable a value of 0.
Inside the variable.cpp file, you have declared an
int variable named
Let’s give the variable a value of 2019.
Type the following commands in the terminal and press enter: