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 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.

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.

C++ Variable Definition:

Variable definition tells the compiler how much storage space and where to create the variable. The variable definition contains data types and list of one or more variables.

C++ variable definition syntax: