Array (array) is a data type tersetruktur within which consists of components - components that have the same data type. In an array is a fixed number of components number. In an array or an array of every kompoenen shown by a unique index. Array index of each component shows a sequence identity that represent data or data contained therein.The simple logic array that can be likened to two people with the same name within a community, to distinguish between the name of the one or the other names are given additional initial for each name.
Array Declaration
Programming language in the writing of any use of the array must dideklarsikan first. Array declaration begins with the array variable name followed by an array index that is written in the "[]", followed by the words and the type of backup of data required.
General Form of Writing
Tanda_pengenal: array [index type .. ..] of the type of data;
Example:
VarA: array [1 .. 4] of integer;B: array [1 .. 5] of string;C: array [1 .. 10] of real;
Keterangnan:A, B, C is an identifier / name of the array variable;1 .. 4: an index of the array type, which indicates the amount of data that can be stored.Integer: indicates that data is inputted integer.
Use of Array Allocation
A. Array Static (Static Array)
model of the declaration of static array is an array where the data type used to have a fixed value. Value used to determine the range in general integer value. Static arrays can also be called Array with index subrange integer type declaration.
General Form
array [indexType1, ..., indexTypen] of baseType
Description = index type show that shows the ordinal data type or element maksimul limits on how much the variable component store.
Example
Var MyArray: array [1 .. 5] of char
Or also
typerange = 1 .. 5;varvalue: array [range] of integer;
B. Array Dynamic (Dynamic arrays)
Array or dynamic array is an array that does not have a fixed range or size. But when the program is executed then the memory for an array dynamically reallocated when we assign a value to the array. Dynamic-array type is characterized by the construction (related) format
General Form
array of baseType
Example
var value: array of Real;
Of the declaration is a declaration of an array of values which have not yet obtained a fixed rate, but only given as a range of data type real. To declare an array that we have to put in a memory array, way is to utilize the functionality of the command sellength.
Selllength (value, 20)
The value of the fragment program for the array has a value range or coverage as much as 20 for real data types, with indeex starting from 0 to 20.
0 komentar:
Posting Komentar