Saturday, 13 August 2016

Representation of a variable in memory

  • It may be mentioned that a computer provides a Random Access Memory (RAM) for storing the executable program code and the data the program manipulates. 
  • This memory can be thought of as a contiguous sequence of bits, each o which is capable storing a binary digit .
  • Typically, the memory is also divided into groups of eight consecutive bits (called bytes). These bytes are sequentially addressed. 
  For example :-
 
           int salary = 65000;
It causes the compiler to allocate a few bytes to represent salary. The binary conversion of 65000 is 1111110111101000. the compiler uses the addresses of the first byte at which salary is allocated to refer to it. As it is int  2 bytes of memory is allocated.

A two-byte integer whose address is 1215

No comments:

Post a Comment

If u need any help,