Arrays are known as a data structure as they can hold more than one value. In order to fully understand arrays it is best to start off with an example.
Name |
Test 1 |
Test 2 |
Bert |
8 |
3 |
Fiona |
5 |
7 |
Sally |
7 |
6 |
George |
7 |
7 |
Fred |
5 |
4 |
We could store these in variables as follows :-
Etc-
This means that by the end we will have 15 separate variables. This is clearly not a good way to store this information. What happens if there was 100 students? We would have 300 variables. By using arrays we can store the above information in just 3 arrays.
Etc
This is much more efficient. What we have effectively done is created a one dimensional table (or just a single column) to store our data in. We have assigned a name to the array, given it a size and then placed data within it.
Arrays work very well with itteration.