• A two dimensional array has two subscripts.
• First subscript is for row and second for column.
• The syntax for declaration of two dimensional array is
data_type arr[row_size][column_size];
• Consider the example int aa[5][5];
Here aa is an integer array of size 5x5
i.e. total 25 elements.
• The array elements are represented using the subscript.
• While storing in memory, each dimension of the array is indexed from zero to it’s maximum size-1.
• The first subscript indicate row and second subscript indicates column.
• For eg. Consider an integer array of size 2x3 as
int b[2][3]={10,20,30,40,50,60};
The array b is represented in memory as
Col.0 Col.1 Col.2
row0 10 20 30
row1 40 50 60
Where,
b[0][0]=10
b[0][1]=20
b[0][2]=30
b[1][0]=40
b[1][1]=50
b[1][2]=60
• First subscript is for row and second for column.
• The syntax for declaration of two dimensional array is
data_type arr[row_size][column_size];
• Consider the example int aa[5][5];
Here aa is an integer array of size 5x5
i.e. total 25 elements.
• The array elements are represented using the subscript.
• While storing in memory, each dimension of the array is indexed from zero to it’s maximum size-1.
• The first subscript indicate row and second subscript indicates column.
• For eg. Consider an integer array of size 2x3 as
int b[2][3]={10,20,30,40,50,60};
The array b is represented in memory as
Col.0 Col.1 Col.2
row0 10 20 30
row1 40 50 60
Where,
b[0][0]=10
b[0][1]=20
b[0][2]=30
b[1][0]=40
b[1][1]=50
b[1][2]=60
No comments:
Post a Comment