### Arrays Introduction

An array is a consecutive group of memory locations that all have the same type. To refer to a particular location or element in the array, we specify the name of the array and the position number of the particular element in the array.

Arrays allow us to do something similar with variables. An array is a set of consecutive memory locations used to store data. Each item in the array is called an element. The number of elements in an array is called the dimension of the array. A typical array declaration is:

```// List of data to be sorted and averaged
int    data_list;
```

This declares data_list to be an array of the three elements data_list, data_list, and data_list, which are separate variables. To reference an element of an array, you use a number called the subscript (the number inside the square brackets [ ]). C++ is a funny language and likes to start counting at 0, so these three elements are numbered 0-2. Consider the following exampe :

#### Example

```#include <iostream>

using namespace std;

int main()
{
float data;  // data to average and total
float total;    // the total of the data items
float average;  // average of the items

data = 34.0;
data = 27.0;
data = 46.5;
data = 82.0;
data = 22.0;

total = data + data + data + data + data;
average =  total / 5.0;
cout << "Total " << total << " Average " << average << '\n';
getchar();
return (0);
}
```

#### Output

```Total 211.5 Average 42.3
```