Variables are simply names used to refer to some location in memory – a location that holds a value with which we are working. Size of variables depends upon data type used to define it.
data-type variable-name ;
int EmployeeId; double Salary;
int EmployeeId = 10; double Salary = 10000.78;
The above line declares a variable names EmployeeId and assigns it a value 10.
The same objective can be achieved in following way:
int EmployeeId; EmployeeId = 10;
|It defines a variable named EmployeeId and occupies a memory (2 bytes) in Computer Memory which can store an integer value.|
EmployeeId = 10;
|This is known as assignment statement. A value 10 is assigned to the variable EmployeeId. The left hand side of = operator (lvalue) must be a variable name while the rvalue can be another variable or some value.|
← Previous Next →
© 2018 BreakInerview