Array 2: Start!
Array 2: Start!
Start!
ARRAY Already discussed in the
previous chapter
One-dimensional
Multi-dimensional
Multidimensional Array?
Will be
Rarely used,
not discussed
Array X has 5 rows and 4 columns Example of 2D array
or Array X is 5x4
Column
Index
Column index
Row Element
Index of X
Row 0 1 2 3
Index X[0,0] = 10
0 10 4 6 17
X[0,1] = 4
1 23 53 16 41 X[0,2] = 6
X[0,3]= 17
2 2 22 33 9 X[1,0] = 23
3 15 16 30 11 X[1,1] = 53
X[1,2] = 16
4 43 12 25 21 …
Array M is 3x4
0 1 2 3
0
1
2
M[0,2]
0 1 2 3 0 1 2 3 0 1 2 3
2D Array declaration
column index:
start from 1
to 2
row index:
variable name start from 1 array type is
of array to 3 integer
2D Array declaration in C language
data_type array_name[rows][columns];
int X[3][2];
2D Array initialization
FOR i = 1 TO 3 DO
FOR j = 1 TO 2 DO
input (X[i][j])
ENDFOR
ENDFOR
Thank you