Embed presentation
Download to read offline

![MULTI-DIMENSIONAL LISTS
Two-dimensional lists are often used to represent tables of
values consisting of information arranged in rows and
columns.
Can define one list for multiple sets of data
List of Lists
Identify a particular table element with two indices.
By convention, the first identifies the element’s row and the second its
column.
Multidimensional arrays can have more than two dimensions.
Code: declaratory is number of rows by number of columns:
list[ROWS][cols]
First declarator is number of rows; second is number of columns](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-2-320.jpg)
![TWO-DIMENSIONAL LIST REPRESENTATION
exams[4][3]
Use two subscripts to access element:
exams[2][2] = 86
exams[0][0] exams[0][1] exams[0][2]
exams[1][0] exams[1][1] exams[1][2]
exams[2][0] exams[2][1] exams[2][2]
exams[3][0] exams[3][1] exams[3][2]
columns
r
o
w
s](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-3-320.jpg)

![TWO-DIMENSIONAL LIST INITIALIZATION
Multidimensional listss can be initialized with list
initializers in declarations.
A two-dimensional list b with two rows and two columns
could be declared and initialized with nested list
initializers as follows:
exams= [ [84, 78],
[92, 97] ]
Rows can have different lengths.
84 78
92 97](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-5-320.jpg)

![TWO-DIMENSIONAL ARRAY AS PARAMETER,
ARGUMENT
Use array name as argument in function call:
getExams(exams, 2)
Use empty [] for row, size declarator for column in
prototype, header:
const int COLS = 2;
// Prototype
void getExams(int [][COLS], int);
// Header
void getExams(int exams[][COLS], int rows)](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-7-320.jpg)

The document discusses multi-dimensional and two-dimensional lists. It explains that two-dimensional lists can represent tables of values arranged in rows and columns, with each element identified by two indices - the row and column. It provides examples of declaring and initializing two-dimensional lists, including nested list initializers. It also covers passing two-dimensional arrays as function parameters.

![MULTI-DIMENSIONAL LISTS
Two-dimensional lists are often used to represent tables of
values consisting of information arranged in rows and
columns.
Can define one list for multiple sets of data
List of Lists
Identify a particular table element with two indices.
By convention, the first identifies the element’s row and the second its
column.
Multidimensional arrays can have more than two dimensions.
Code: declaratory is number of rows by number of columns:
list[ROWS][cols]
First declarator is number of rows; second is number of columns](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-2-320.jpg)
![TWO-DIMENSIONAL LIST REPRESENTATION
exams[4][3]
Use two subscripts to access element:
exams[2][2] = 86
exams[0][0] exams[0][1] exams[0][2]
exams[1][0] exams[1][1] exams[1][2]
exams[2][0] exams[2][1] exams[2][2]
exams[3][0] exams[3][1] exams[3][2]
columns
r
o
w
s](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-3-320.jpg)

![TWO-DIMENSIONAL LIST INITIALIZATION
Multidimensional listss can be initialized with list
initializers in declarations.
A two-dimensional list b with two rows and two columns
could be declared and initialized with nested list
initializers as follows:
exams= [ [84, 78],
[92, 97] ]
Rows can have different lengths.
84 78
92 97](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-5-320.jpg)

![TWO-DIMENSIONAL ARRAY AS PARAMETER,
ARGUMENT
Use array name as argument in function call:
getExams(exams, 2)
Use empty [] for row, size declarator for column in
prototype, header:
const int COLS = 2;
// Prototype
void getExams(int [][COLS], int);
// Header
void getExams(int exams[][COLS], int rows)](https://image.slidesharecdn.com/multilists-160324200526/85/Multi-Dimensional-Lists-7-320.jpg)
