Arithmetics
To store integer numbers (whole numbers), we use the int
type.
This line creates an int
called age
and set the value to 18
:
int age = 18;
Arithmetic operations such as addition and subtraction can be applied to integers. This line prints out the age
added by 5
:
std::cout << "5 years later I will be " << (age + 5) << std::endl;
Note that (age + 5)
is enclosed within parentheses to make the fact the +
operator is executed before the <<
operator explicit.
Make the program prints about 20 years ago instead.
year_span
to be 20
.