Course Content
Introduction to C++
With the help of variables, we can "borrow" the memory of our PC and use it to store any data to operate on it later. Creating a variable consists of two parts – declaration and initialization. Variable names in C++ can consist of letters and numbers but cannot start with numbers, nor can they contain spaces or arithmetic operators (such as +, -, etc.).
To declare a variable, you need to specify the stored data. In our case, it is an integer value with the name "myVariable"
.
Under the hood of the name is the address of the piece of memory that we "borrowed".
Now, to initialize the variable, it is necessary to drop something into that section of memory, in our case, it is an integer.
Note
Number 0 also takes up memory :)
main.cpp
In the case of declaring several variables that contain data of the same kind, it is convenient to indicate the type of information only once (all numbers are integer):
main.cpp
or
main.cpp
What is variable?
Select the correct answer
Why are variables used?
Select the correct answer
Section 2.
Chapter 1