What is variable and what is the rule of variables




A quantity whose values may change during execution of the program is called variables.It is represented by symbol or name.

A variable represents a storage or memory location in the computer memory.Data is stored in memory location.The name of the memory location is, i.e the variable name remain fixed during execution of the program but the data stored in the location may changed from time to time.

A variable is also known as object in C++.In C++, a variable name consist of alphabets and digits.

Rules for Writing Variable Names

Following are the rules for writing a variable name is C++ programming.


  1. The first character of variable is must be an alphabetic character
  2. Underscore can be used as a first character of variable name.
  3. Blank space are not allowed in a variable name.
  4. Special character,such as arithmetic operation #,can't not be used as a variable names.
  5. Reserved words cannot be used as a variable name.
  6. The maximum length of variable name is depend upon the compiler of C++.
C++ is a case -sensitive language.Thus variable name with same spelling but different case are treated as different variable name,For example variable 'Pay' and 'pay' are two words.

No comments:

Powered by Blogger.