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

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. 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. (NOTE: if you are unclear what bytes and memory locations are, please read Chapter 3.)

To put a value in memory, and later to get it back, 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 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:

box with 123 in it

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

QUESTION 2:

Must a variable always have a data type?