Placement of Variable Declarations

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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.195.204