go to previous page   go to home page   go to next page hear noise

Answer:

Yes — that is why is is called a variable.


Variables

The billions 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. It just holds bit patterns.

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 may now hold data, and some that previously held data may now hold machine instructions.

Using the same memory for both instructions and data was the idea of John von Neumann, a computer pioneer. (If you are unclear about bytes and memory locations, please read Chapter 3.)

variable — a named location in main memory which uses a particular data type to hold a value.

Recall that a data type is a scheme for using bit patterns to represent a value. Think of a variable as a little box made of one or more bytes that can hold a value using a particular data type.

To put a value in memory, and later to get it back, a program must have a name for each variable.

Variables have names such as payAmount. (Details will be given in a few pages.)

box with 123 in it

QUESTION 2:

Must a variable always have a data type?