Member functions getMinimum
, getMaximum
, outputBarChart
and outputGrades
each loop through array grades
by using nested range-based for
or counter-controlled for
statements. For example, consider the nested for
statement (lines 59–68) in member function getMinimum
. The outer for
statement loops through the rows that represent each student
and the inner for
loops through the grades of a given student. Each grade is compared with variable lowGrade
in the body of the inner for
statement. If a grade is less than lowGrade
, lowGrade
is set to that grade. This repeats until all rows and columns of grades
have been traversed. When execution of the nested statement is complete, lowGrade
contains the smallest grade in the two-dimensional array
. Member function getMaximum
works similarly to member function getMinimum
.