Student Grade Array - { int highGrade = grades[0][0] for (...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using std::cout using std::endl const int students = 5 // number of students const int exams = 4 // number of exams int maximum(int [][ exams ], int, int ) double average( int [], int ) void printArray( int [][ exams ], int, int ) int main() { int studentGrades[ students ][ exams ] = { { 77, 68, 86, 73 }, { 96, 87, 89, 78 }, { 70, 90, 86, 81 }, { 99}, { 100, 72, 64} } cout << "The array is:\n" printArray( studentGrades, students, exams ) cout << "\nHighest grade: " << maximum( studentGrades, students, exams ) << '\n'
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 for ( int person = 0 person < students person++ ) cout << "The average grade for student " << person << " is " << average( studentGrades[ person ], exams ) << endl return 0 } // Find the maximum grade int maximum( int grades[][ exams ], int pupils, int tests )
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int highGrade = grades[0][0] for ( int i = 0 i &lt; pupils i++ ) for ( int j = 0 j &lt; tests j++ ) if ( grades[ i ][ j ] &gt; highGrade ) highGrade = grades[ i ][ j ] return highGrade } // Determine the average grade for a particular student double average( int setOfGrades, int tests ) { int total = 0 Sheet1 Page 3 for ( int i = 0 i &lt; tests i++ ) total += setOfGrades[ i ] return static_cast&lt; double &gt;( total ) / tests } // Print the array void printArray( int grades[ exams ], int pupils, int tests ) { cout &lt;&lt; &quot; [0] [1] [2] [3]&quot; for ( int i = 0 i &lt; pupils i++ ) { cout &lt;&lt; &quot;\nstudentGrades[&quot; &lt;&lt; i &lt;&lt; &quot;] &quot; for ( int j = 0 j &lt; tests j++ ) cout &lt;&lt; grades[ i ][ j ] cout &lt;&lt; endl } }...
View Full Document

Page1 / 3

Student Grade Array - { int highGrade = grades[0][0] for (...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online