Ict wk4
Ict wk4
TOPIC:
BASIC PROGRAMMING III
(ONE DIMENSIONAL ARRAY)
PERFORMANCE OBJECTIVES
At the end of this lesson, students should be able to:
• Definition of Array
• Operations on Array
• Simple BASIC program on one-dimensional array.
DEFINITION
ARRAYS
▪ An array is used to store multiple values in a single variable. To create an array,
use the DIM [Dimension] statement.
▪ The term table is also known as an array. An array variable is a data structure
consisting of an ordered set of elements of the same data type. One advantage of
arrays is that they allow for the logical grouping of data of the same type.
ADVANTAGE OF STORING DATA IN TABLES
• Each item of data does not have a unique variable name.
540 50 40 150
The cells are grouped together to form a one –dimensional table.
Cell 3
Cell 1 Cell 4
Cell 2
DIM Statement
• Arrays are defined in a DIM statement and the total number of elements of an array
is given in parenthesis. An element of an array is specified by its subscript value.
Solution:
10 REM “Declaring the names of football clubs”
11 DIM QS (5)
12 FOR Y = 1 to 5
13 READ Qs (Y)
14 NEXT Y
15 PRINT DS (Y)
16 DATA “Manchester United”; “Chelsea”; “Arsenal”;
17 DATA “Manchester City”; “Swansea”
18 END