- Arrays are fixed‑length structures containing elements of the same data type.
- Elements are accessed by consecutive index numbers.
- Best practice: explicitly state the lower bound of the array.
- Square brackets are used to indicate array indices.
Declaration
- One‑dimensional array:
DECLARE <identifier> : ARRAY[<l>:<u>] OF <data type>
- Two‑dimensional array:
DECLARE <identifier> : ARRAY[<l1>:<u1>, <l2>:<u2>] OF <data type>
- Only one index value is used for each dimension inside the brackets.
Usage Notes
- Statements should not refer to a group of array elements collectively.
Example (incorrect):
StudentNames[1 TO 30] <-- ""
- Instead, use a loop structure to assign values individually.
Example (correct):
FOR i <-- 1 TO 30
StudentNames[i] <-- ""
END FOR
No comments:
Post a Comment