A variable definition associates a memory location to the variable name. A variable is an entity which may vary during the program’s execution. A variable can hold only one value at a time during program execution. It’s value can be changed during program execution.
C++ allows declaration of variables before and after executable statements. It allows declaration of the variables any where in the scope i.e. a variable can be declared right at where the place of it use.
A variable is an object that may take on values of the specified type. The variable must be declared by specifying the data type and identifier.
Rules for constructing variable names:
- A variable name can be any combination of alphabets, digits or underscore.
- The first character in variable name must be an alphabet.
- No commas or blanks are allowed within a variable name.
- No special symbols other than underscore can be used in variable name.