Two Dimensional Arrays
How cells are referred to using subscript or index notation
arrayB[0][0] |
arrayB[0][1] |
arrayB[0][2] |
arrayB[0][3] |
arrayB[1][0] |
arrayB[1][1] |
arrayB[1][2] |
arrayB[1][3] |
arrayB[2][0] |
arrayB[2][1] |
arrayB[2][2] |
arrayB[2][3] |
Horizontal elements beginning with cell identified as arrayB[0][0] are in row 1
Vertical elements beginning with cell identified as arrayB[0][1] are in column 2
This array is referred to as a 3x4 array (3 rows and 4 columns)
When listing subscripts or indices the row is given first followed by the column
Rows are in a horizontal line, columns are in a vertical line
Contents of cells
4 |
5 |
8 |
-3 |
2 |
9 |
1 |
5 |
6 |
7 |
21 |
14 |
The contents of the cells in row 1 are 4, 5, 8, -3
The contents of cells in column 4 are -3, 5, 14
The cell whose subscripts are 1, 2 (arrayB[1][2] ) holds the value 1
using namespace std;
using namespace std;