Multi-dimensional Arrays
9. Multi-dimensional Arrays#
In the previous two chapters, we discuss one-dimensional arrays. One-dimensional arrays help in writing down a list of items that relate to one thing, for example, the grades of one student, or the grades of a class in one assignment. It is more powerful if we can write down the grades of all students in all course assessments. This would look like a multi-column table like this:
Student Name1  | 
Lab 1  | 
Lab 2  | 
Lab 3  | 
Lab 4  | 
Lab 5  | 
|---|---|---|---|---|---|
Muhammad Ali  | 
10  | 
9  | 
10  | 
10  | 
9  | 
Whitney Houston  | 
7  | 
10  | 
1  | 
9.5  | 
8  | 
Elon Musk  | 
4  | 
8  | 
7  | 
3  | 
6  | 
Melba Mouton  | 
10  | 
10  | 
7  | 
10  | 
11  | 
Malala Yousafzai  | 
9.5  | 
9  | 
9.5  | 
8  | 
7  | 
Steve Jobs  | 
9.5  | 
8  | 
9  | 
10  | 
9  | 
Lionel Messi  | 
10  | 
10  | 
10  | 
10  | 
10  | 
Mohamed Salah  | 
11  | 
11  | 
11  | 
11  | 
11  | 
- 1
 All names referred here are fictional character names, and any similarities between these names and reality is probably by coincidence.