Array is a structured data type that can hold some data which has same data type. Every element in an array has an index and it can be individually accessed. In Pascal, we can have one-dimensional array or n-dimensional array.
To declare one-dimensional array that can hold six character, we can us this statement :
Type
OneDimensionalArray = array[1..6] of char;
Var
TheData : OneDimensionalArray;
Or you can use this statement :
Var
TheData : array[1..6] of char;
The statement above declares an array that can hold six elements. It is called static array, because it has a fix amount of data. While a dynamic array does not have a fix amount of data.
To access an element in an array use this syntax :
ArrayVariableName[ArrayIndex];
Example :
TheData[3] := ‘A’;
Writeln(TheData[3]);
Readln(TheData[3]);
Example program :
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
i : integer;
TheData : array[1..5] of char;
begin
//assigning values to array
TheData[1] := 'A';
TheData[2] := 'B';
TheData[3] := 'C';
TheData[4] := 'D';
TheData[5] := 'E';
for i := 1 to 5 do writeln(TheData[i]);
readln;
end.
You can download the complete code here.
wow wow selalu ada info yang baru, makasih infonya
ReplyDeletemoga sukses selalu
thank you pakde, for following the tutorial..
ReplyDeletemakasih ya infonya...
ReplyDeletesalam kenal...
s 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.
ReplyDelete