Some values should change as a program runs; others are fixed rules. The number of visitors can change, but the approved capacity of a room should not accidentally be overwritten while counting them.
Place const before a type to make an object non-modifiable through that name:
#include <iostream>
int main() {
const int tablesPerRoom = 5;
std::cout << "Tables per room: " << tablesPerRoom << "\n";
return 0;
}
const int still stores an integer. The extra word says that, after initialization, the program must not assign a replacement value to this object. Give it its value in the declaration. A later assignment to this constant would be rejected by the compiler, so the complete example contains no such assignment.
A meaningful constant name explains a number's role. Seeing tablesPerRoom in a calculation tells a reader more than seeing an unexplained 5. Constants also give you one place to edit a rule when preparing a new version of the source.
Editing the source and assigning during execution are different actions. You can replace 5 in the example before compiling a new program. But once that program initializes tablesPerRoom, a later assignment to it is not allowed. For your task, edit the initializer rather than adding an assignment below the declaration.
The starter contains const int capacity = 0;. Zero is a temporary value, not the real room limit. Replace its initializer with the approved capacity while retaining const int. The existing output statement will show whether the new source value has been used.
const int capacity to 30, keeping it constant.Edit main.cpp, press Run to inspect the Console, then Submit to check these results.