|
Do you imagine that a variable can change its value? A good answer might be:Yes---perhaps that is why is is called a variable. |
Variables
The millions of bytes of main storage in your home computer are used to
store both machine instructions and data.
The electronic circuits of main memory (and all other types of memory) make
no distinction between the two.
When a particular program is running, some memory locations are used
for machine instructions and others for data.
Later, when another program is running in the same memory
some of the bytes that previously held machine instructions
will now hold data, and some that previously held data
will now hold machine instructions.
Using the same memory for both instructions and data
was the idea of In order to put data in memory, and later get it back again, a program must have a name for each section of memory that it uses. variable --- a name for a location in main memory which uses a particular data type to hold a value.Recall that a data type is a scheme for using the bit patterns of main storage to represent data. (This definition of variable is not very good, by the way. It will have to be changed later on when you learn more about what is "really going on.") You can think of a variable as a little box made up of one or more bytes that can hold a value of a particular data type: Variables have names such as payAmount.+--------------+ | | | 123 | payAmount; type is "long" | | +--------------+ |
QUESTION 2:Does the number of bits used for a primitive variable ever change? Click Here after you have answered the question |