arrays

=3.2.3 b= = =
 * =define and use arrays (one- and two-dimensional) for solving simple problems, including initialising arrays, reading data into arrays and performing a simple serial search on a one-dimensional array;=

= Arrays = A computer programming term. An array is a data structure, which allows a set of items of identical data type to be stored together using the same identifier name. Arrays are declared in a similar way to standard variables, except that the array size and dimensions are included. For example, the following declares an array that reserves five locations in memory and labels these as ‘Names’:
 * Key Word || Definition ||
 * Array || is a set o data items of the same type grouped together using a single identifier. ||

DIM Names(4) As String

The five individual locations are Names(0), Names(1), Names(2), Names(3), Names(4).

Each data item is called an element of the array. To reference a particular element a programmer must use the appropriate index. For example, the following statement assigns data to the 5th element:

Names(4) = “Johal”

Arrays simplify the processing of similar data. An algorithm for getting five names from the user

and storing them in the array Names is shown below:

Dim Names(4) As String For i=0 to 4 Input Value Names(i)=Value Next i