N-dimensional array is an array that has two or more indexes. To understand the concept of n-dimensional array, see the picture below.
To declare two-dimensional array that can hold six character, we can us this statement :
Type
TwoDimensionalArray = array[1..2, 1..3] of char;
Var
TheData : TwoDimensionalArray;
Or you can use this statement :
Var
TheData : array[1..2, 1..3] of char;
To access an element in two-dimensional array use this syntax :
ArrayVariableName[ArrayIndex1,ArrayIndex2];
Example :
TheData[1,3] := ‘A’;
Writeln(TheData[1,3]);
Readln(TheData[1,3]);
Example program :
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
i, j : integer;
TheData : array[1..2, 1..3] of char;
begin
//assigning values to array
TheData[1,1] := 'A';
TheData[1,2] := 'B';
TheData[1,3] := 'C';
TheData[2,1] := 'D';
TheData[2,2] := 'E';
TheData[2,3] := 'F';
for i := 1 to 2 do
begin
for j := 1 to 3 do writeln(TheData[i,j]);
end;
readln;
end.
You can download the complete code here.
How to declare a three-dimensional array and to use it in a program ?
codingnya mantafff mas, walau mudenk dikit2. cocok untuk mereka yang lagi ada tugas Array nich
ReplyDeletethanks, kunjungan balik nih . . .tukeran review alexa yukk . .
ReplyDeletegak mudeng tentang ... karena bukan bidangnya pak like. ...
ReplyDeletes The best and a lot of secret drop-shipping suppliers in the world which will provide your products globally available for you directly to your customers doors. Also get the best drop-shipping manufacturer on your organization.
Delete