Yes — that is why is is called a variable.
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 program is running, some memory locations are used
for machine instructions and others for data.
Later, when another program is running
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. 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:
payAmount type is "long"
Variables have names such as payAmount
.
(Details will be given in a few pages.)
Must a variable always have a data type?