Skip to main content

Variables

Variables:
          A quantity whose value may change during execution of the program is called variable.It is represented by a symbol or a name

Rules for writing variable names:
The following are the rules for writing a variable name in a program in c++:
  • The first character of variable name must be an alphabetic character.
  •  Underscore can be used as first character of variable name.
  • Blank spaces are not allowed in a variable name.
  • Special character, such as arithmetic operators,#,^,cannot be used in a variable name.
  • Reserved words cannot be used as variable names.
  • The maximum length of a variable name depends upon the compiler of c++.
  • A Variable name declared for one data-type cannot be used to declare another data-type.
Example:
 variables 'Pay' and 'pay' are two different variables.

Comments

Popular posts from this blog

Programs

PROGRAM 1: #include<iostream> using namespace std; int main() {    cout<<"HELLO WORLD";    return 0; } OUTPUT OF THE PROGRAM: HELLO WORLD                 ............................................................................................................................. PROGRAM 2: #include<iostream> using namespace std; int main() {    cout<<"c++ is best language";    return 0; } OUTPUT OF THE PROGRAM: c++ is best language      .............................................................................................................................                    

Initialization Of Variables

Initialization Of Variables:   When a variable is declared,a memory location is assigned to it.The value in that memory location is  also assigned to the variable.This preassigned value of a variable,if not used by mistake,may result in incorrect result.To avoid this situation, a known value is  assigned to the variable.This value is assigned to the variable at the time of its declaration.Assigning a known value to a variable at the time of its declaration is called initializing of the variable.        For example, to declare variables a,b and c of integer type and assigning values a=220 and b=70,the statement is written as:            int a=220,b=70,c;