Using Arrays
You have already spent time this
year understanding variables. There are two kinds of variables: Numeric
and String. So far in
our course we have used a variable to represent a single unique item.
One way of visualizing variables is that they are a mailbox.
Each mailbox has a name (the variable name) and has information which is
stored in the box.
name1$
name2$
a$
speed
time
x
| George |
Armando |
23 |
44 |
13 |
1000 |
Note that a$ is a string variable and contains string
information even though it contains a number. That number could not
be used for calculation.
Variables can contain different values. This is
the same concept that you learned in Algebra. What is different in
programming is that when we create a variable we are creating a place in
memory to store the value. We are creating the mailbox.
The difference between
arrays and variables is that arrays are lists of variables. For example
we may have a number of names that we want to have in a list. We
could visualize a single dimensioned
array this way.
Name$( )
| Frank |
| Rudy |
| Muraad |
| Lisa |
| Elmira |
Definitions:
Numeric Variable: Numeric
variables are used for storing numbers (numbers with which we want to do
calculations.) If we need to add or subtract or use a variable in
a formula we need for that variable to be numeric.
String variables are
used for storing alpha-numeric information. Alpha-numeric information
contains numbers (not used in calculations), letters and symbols.
Single-Dimension
array: A Single-Dimension array has only a single column of related
information.