teach-ict.com logo

THE education site for computer science and ICT

1. Introduction

Most programs will need to keep track of data. One way to do this is to store the data as independent variables.

Storing the names of players on a football team might look like this:

               player1 "John Smith"

               player2  "Simon Says"

               player3  "Jimmy Widget"
                 ... and so on
  

So in this example, there would be eleven variables.

The problem with this, is it does not show that there is a relationship between the names - i.e. that they are all part of the same football team.

To do that, you need a better way of organising the data. There are several types of data structure to choose from, but for this task the most suitable is the array.

An array allows you to store related data together as a single collection. For example an array containing 11 elements can be used to store the football team members above.