MaxVal2D - max = maxi2 score call cout<<"The...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Using arrays as arguments in a function call // Function maxi2 returns the maximum element in the 2D array. // Author: Charles Swanson #include<iostream> using namespace std; const int NROWS=4, NCOLS=3; int maxi2(int results[][NCOLS] ); // declaration int main() { int max, score[NROWS][NCOLS] = {7,4,2,11,9,8,2,2,0,5,6,7};
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: max = maxi2( score ); // call cout << "The maximum number is " << max << endl; return 0; } int maxi2( int results[NCOLS] ) { int i, j, max = results[0][0]; for( i = 0; i < NROWS; i++) for(j = 0; j < NCOLS; j++) { if( max < results[i][j] ) max = results[i][j]; } return max; }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online