Variables, Constants, and Arrays
Chandan Sengupta · 2012
Variables and constants are two of the most important building blocks for writing C++ expressions and statements. This chapter discusses the rules of creating and using variables and constants in C++. When one uses the name of the variable anywhere in the program, the computer substitutes for it whatever data is stored in the variable's storage space at that time. Variables hold data temporarily in computer's RAM and just for the duration of the variable's existence. Constants are fixed values that cannot change in the program. C++ provides for three kinds of constants: literal, symbolic, and enumerated. An array is a collection of variables with the same name and data type. One can use the elements of an array to store any data as long as they are of the same data type as the array itself. In C++, the dimensions of an array are fixed at the time it is declared and it cannot be changed afterwards.