Two Dimensional Arrays

This chapter expands our discussion on one-dimensional arrays to two dimensional arrays. A two dimensional array is a data structure that contains a collection of cells laid out in a two dimensional grid, similar to a table with rows and columns although the values are still stored linearly in memory. Each cell in a two dimensional array can be accessed through two indexes that specify the row number and column number respectively. Like s one dimensional array, the range of each index is from zero to the size of the row or column minus one. A nested for loop is commonly used to initialize, manipulate, and access the values in a two dimensional array.

2. Table of Student Grades


Answer:

Yes

Table of Student Grades

Annotation 2020-03-26 204636Imagine a class of 7 students that have a quiz every week for 5 weeks. The instructor records the grades in a table. A particular cell of the table is designated by student number and week number. For example:

      • The grade for student 0 week 1 is 42
      • The grade for student 3 week 4 is 93
      • The grade for student 6 week 2 is 78

To specifying a cell use row and column indexes like this:

gradeTable[ row ][ col ]

As with one dimensional arrays, indices start at zero. For example:

      • gradeTable[ 0 ][ 1 ] is 42
      • gradeTable[ 3 ][ 4 ] is 93
      • gradeTable[ 6 ][ 2 ] is 78

Question 2:

What is:

gradeTable[ 0 ][ 0 ]
gradeTable[ 1 ][ 1 ]
gradeTable[ 3 ][ 4 ]
gradeTable[ 5 ][ 2 ]