Declarations of variables can be placed almost anywhere in a program, but they must appear before their corresponding variables are used in the program. For example, in the program of Fig. 2.5, the declaration in line 9
int number1 = 0; // first integer to add (initialized to 0)
could have been placed immediately before line 14
std::cin >> number1; // read first integer from user into number1