Arrays and Do Loops
Arrays and Do Loops
Arrays and Do Loops
GCE SOLUTIONS
Siddharth Kumar, Principal Programmer
11
Derive value from excellence…
Given Data
12
Derive value from excellence…
The Code
13
13
Derive value from excellence…
The Output
Added Data
14
14
Derive value from excellence…
Func.ons: Dim, Lbound, Hbound
• Determining the Number of Elements in an Array Efficiently
• DIM returns the number of elements in an array dimension.
• HBOUND returns the value of the upper bound of an array dimension.
• LBOUND returns the value of the lower bound of an array dimension.
• form of the DIM func3on is: DIMn(array-name)
• LBOUND func3on: LBOUNDn(array-name)
• HBOUND func3ons :HBOUNDn(array-name)
• where n is the specified dimension that has a default value of 1.
Example: array mult{2:6,4:13,2} mult1-mult100;
Syntax Alterna.ve Syntax Value
HBOUND(MULT) HBOUND(MULT,1) 6
HBOUND2(MULT) HBOUND(MULT,2) 13
HBOUND3(MULT) HBOUND(MULT,3) 2
Derive value from excellence…
Use of Func.ons DIM, LBOUND & HBOUND IN MULTI-DIMENSIONAL ARRAY
18
Derive value from excellence…