成人快手

1-D array

1-D Arrays allow programmers to store data in a list (provided that the data is of the same data type).

For example, to store a list of Scottish cities you could create a 1-D array.

A programmer can define the number of variables held in a list when they create a 1-D array.

Index

An index is created to be able to identify each variable in the list. The index will start at the value 0.

Eg to store the name of Scottish cities, a 1-D array could be created with seven different index values that identify each item of data. In reference language this could be represented as:

DECLARE scottishCities INITIALLY ["Glasgow", "Dundee", "Perth", "Aberdeen", "Stirling", "Edinburgh", "Inverness"]

Scottish cities0123456
GlasgowDundeePerthAberdeenStirlingEdinburghInverness
Scottish cities
0Glasgow
1Dundee
2Perth
3Aberdeen
4Stirling
5Edinburgh
6Inverness

Number of elements

It is common to identify the number of elements that need to be stored in the array when you use software development langugages.

Eg a 1-D array for Scottish cities held in Visual Basic could be represented as:

Dim scottish_cities (7) as String

The value shown in brackets determines the number of elements that are held within the 1-D array.

Related links