2 2darrays
2 2darrays
0 1 2 3 4
MULTI DIMENSIONAL ARRAY
• An array of arrays is called as multi dimensional
array.
• Multi dimensional array can be of two dimensional
array or three dimensional array or four
dimensional array or more...
• Most popular and commonly used multi dimensional
array is two dimensional array.
• The 2D array is organized as matrices which can be
represented as the collection of rows and columns.
TWO DIMENSIONAL ARRAY
• Declaration of Two Dimensional Array
Syntax:
datatype arrayName[rowSize][columnSize];
2 7 8 9
TWO DIMENSIONAL ARRAY
• Declaration of Two Dimensional Array
Syntax:
datatype arrayName[rowSize][columnSize];
Col 0 Col 1
Row 0 a[0][0] a[0][1]
a
a[1][0] a[1][1]
Row 1
Row 2 a[2][0] a[2][1]
TWO DIMENSIONAL ARRAY
• Initialization of Two Dimensional Array
Syntax:
datatype arrayName[rows][colmns] = {{r1c1, r1c2, ...},{r2c1,
r2c2,...}...} ;
2 7 8
TWO DIMENSIONAL ARRAY
Homework:
• Eg: int a[3][4] ;
The above declaration of two dimensional array reserves
memory locations in the form of 3 rows and 4 columns.