Matrices
Matrices
Arrays of Arrays
(And, yes, you can have:
arrays of arrays of arrays, and
arrays of arrays of arrays of arrays, and
arrays of arrays of arrays of arrays of
arrays, and….)
Arrays (review):
→ Characteristics:
→ Sequential (one item after another one)
→ So there’s an order to the items – a first one, a 32
second one, a third one, etc.
→ It consists of one type
→ So all the items are ints, or all are strings, or all
are floats, or all are Boolean values, etc.
→ It has a size (i.e., it has a specific number of items)
→ To create: int arr_var[10];
→ To put a value in: arr_var[8] = 32;
Array of Arrays: Matrix!!!
(Did not get those movies…)
0
→ Row first, then column:
1 42
→ mat_var[1][3] = 42;
2
0 1 2 3 4
→ To declare: int mat[4][7]; // where 4 is the number of rows and 7 is the number of values in each row.