Saturday, January 21, 2012

Assignment operator and variable representation

concept of variable as  small post box
Rules to Write Variable.
1.First Letter Character
2.Underscore _ (Not Recommended)
3.Can’t use real numbers (Syntax Error)
    int num1;
Variable is the name of a location in the memory
    e.g. x= 2;
how variable stores in a memory

In a program a variable has:
   1.Name
   2.Type
   3.Size
concept of variable

   4.Value
i.e
int x = 2;
float y = 3.6
Assignment Operator
   =
x=2






 2 






In defining variables LHS must be equal to the RHS here some examples

L.H.S = R.H.S.
X+ 3 = y + 4 Wrong
Z = x +4
x +4 = Z Wrong
Example Of Assignment Operator


#include <iostream.h>
void main ()
{
int a, b;
a = 10;
b = 4;
a = b;
b = 7;
cout << "a :";
cout << a;
cout << " b :";
cout << b;
}