Student Grade Array - int highGrade = grades[0[0 for int i...

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 < pupils i++ ) for ( int j = 0 j < tests j++ ) if ( grades[ i ][ j ] > 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 < tests i++ ) total += setOfGrades[ i ] return static_cast< double >( total ) / tests } // Print the array void printArray( int grades[ exams ], int pupils, int tests ) { cout << " [0] [1] [2] [3]" for ( int i = 0 i < pupils i++ ) { cout << "\nstudentGrades[" << i << "] " for ( int j = 0 j < tests j++ ) cout << grades[ i ][ j ] cout << endl } }...
View Full Document

This note was uploaded on 05/16/2010 for the course CISCO EST61 taught by Professor Miller during the Spring '10 term at Fresno City College.

Page1 / 3

Student Grade Array - int highGrade = grades[0[0 for int i...

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