C++ Variable
C++ variable are used to store data in memory location. The value stored in variable may be changed depends on program execution. Each variable in programming language has its own specific types. These specific data types determine the size and layout of the variable's memory.
Rules of C++ Variable Declaration:
- C++ variable name can be declared with small letters a-z, capital letters A-Z, digits 0-9, and underscore character.
- First letter of variable must be underscore or letter.
- C++ is case sensitive. Capital and small letters are treated different.
int age,AGE;
int _id;
float value1;
What to Avoid While C++ Variable Declaration
- Variable declaration cannot be started with digits 0-9.
- Special characters such as $, # are not allowed.
- C++ keywords cannot be used as variable.
- Blank space cannot be used as variable.
int 1value; //invalid
int #id; //invalid
char double; //invalid