Store values in variables and read what the user types.
In this video:
- Declaring a variable: its type first, then its name, as in
int age; intholds whole numbers, negative and positive- Naming rules: letters, digits and
_, but a name can't start with a digit - Initializing with
int age = 10;orint age{10}; - Braces refuse to lose data:
int age{10.5};is an error, whileint age = 10.5;quietly keeps only 10 int age{};starts at 0- Changing a value later with
age = 20; const int age{10};can never change- Reading input with
std::cin >> age;