A notice can contain data as well as fixed words. If the room has a certain number of chairs, a useful name lets the program remember that count.
A variable is a named object that stores a value. This declaration creates and initializes one:
#include <iostream>
int main() {
int tables = 6;
std::cout << "Tables: " << tables << "\n";
return 0;
}
Read int tables = 6; as: create an integer variable named tables, with the initial value 6. int is the type; it stores whole numbers such as counts. The name is chosen by the programmer. The equals sign supplies the starting value here, and the semicolon ends the declaration.
The output statement uses tables without quotes, so it prints the stored number. Writing "tables" would instead print those six letters. Chaining << lets a label, a value, and a newline share one output statement. C++ does not add a space between them automatically; the label contains its own trailing space.
Choose names that explain what the values mean. Names may contain letters, digits, and underscores, but cannot begin with a digit or contain spaces. Uppercase and lowercase differ: chairs and Chairs are different names. Language words such as int are reserved.
In main.cpp, chairs starts at zero so the unfinished program can still run. Replace that temporary value in the declaration, not in the output statement. The output already reads chairs, so changing the stored count is enough to change what it displays.
chairs to 18 so the supplied output shows Chairs: 18.Edit main.cpp, press Run to inspect the Console, then Submit to check these results.