High-level Programming Language (Pascal)
Arrays
for example,
¡@¡@StudentName[3] which access the third element of the array StudentName
Declaration
of a One Dimensional Array
¡@¡@var ArrayName : array [<Index>] of <Element_type>
Copying an Array
¡@for i := 1 to SizeOfArray do
¡@¡@Array1[i] := Array2[i] ;
Initialization of Array
¡@for i := 1 to ClassSize do
¡@¡@begin
¡@¡@¡@StudentName[i] := '' ;
¡@¡@¡@TestScore[i] := 0
¡@¡@end;
Input Data in an Array
¡@for i := 1 to ClassSize do
¡@¡@begin
¡@¡@¡@write ('Please enter the name : ');
¡@¡@¡@readln (StudentName[i])
¡@¡@end;
Declaration of a Two Dimensional Array
¡@¡@var ArrayName : array [<Row_Index>, <Col_Index>] of <Element_type>
¡@var StudentActivity : array [1 .. 40, 1..3] of string;
the array StudentActivity contains (40 - 1 + 1) ¡¦ (3 - 1 + 1) = 120 elements
¡@var StudentName : array ['A'..'E', 1..40] of string ; {string array}
¡@¡@¡@TestScore : array ['A'..'E', 1..40] of real ; {real number array}
Using nested for loop to initialize, copy, input and output two dimensional array
for example, to initialize 5 rows ¡Ñ 7 columns Num_Table to zero
¡@for Row := 1 to 5 do
¡@¡@for Column := 1 to 7 do
¡@¡@¡@Num_Table [Row, Column] := 0