Friday, December 21

Array Variables

An array is a group of table or values referenced by the same variable name. Each element in an array is referenced by an array variable that is a sub-scripted integer. The sub-script is enclosed within parenthesis (brackets).
An array variable name has as many sub-scripts as there are dimensions in the array. The maximum number of dimensions for an array in BASIC is 255. The maximum number of elements per dimension is 32767.
Example 9
N (10)
M (1,4)
N (10) references a value in one dimension array while M(1,4) two dimension array.
For example M(1,4) could be used to represent a two - row, five column array such as the following

Table C 2.12 String Variables    

Column     0        1         2          3        4
Row 0      5        10       15       20       25
Row 1      35      45       55       65       75
In this example
Element M (1,2) = 55
Element M (0,3) = 20
Where, M(1,2) represents the element of first row (Row 1) and second column (column 2) i.e. 55.
Note : Rows and columns begin with 0 not 1.
The arrays are useful for storing tabular data.      

No comments:

Post a Comment