Name: ________________________________ Section: _________________

Honor Code Acknowledgment: ___________________


Random Quiz # 4

CPS 100e, Fall 1995

Due: September 28


In both functions below assume that matrices are "full", i.e., use member functions Rows() and Cols() to determine the number of rows and columns, respectively.

Problem 1: Michael's Array Order (at the beach) 2 points

Write the function ColumnSum whose header is given below. The function returns the sum of the values in column col of two-dimensional matrix mat .
    int ColumnSum(const Matrix < int > & mat, int col)
    // precondition: 0 <= col < mat.Cols(), 
    // postcondition: returns sum of all values in column col of mat
    {







    }

Problem 2 : MadMatrixMax 2 points

Write the function MaxValue that returns the largest value stored in the matrix a .
    int MaxValue(const Matrix < int > & a)
    // precondition: a contains a.Rows() rows and a.Cols() columns
    // postcondition: returns the largest of the values stored in a