int findMax( int x[][NUMCOLS], int nrows ) { int r, c; int max = x[0][0] ; for ( r=0; r<nrows; r++ ) for ( c=0; c<NUMCOLS; c++ ) if (x[r][c] > max ) max = x[r][c] ; return max; }
Comment:
Notice how max
is initialized.
Setting max
to zero would not work.