Hi im reading a book and stuck in arrays
heres the fragment of code which i cant understand
in the above codeCode:for ( int student = 0; student < students; student++ ) { cout << "Student " << setw( 2 ) << student + 1; // output student's grades for ( int test = 0; test < tests; test++ ) cout << setw( 8 ) << grades[ student ][ test ]; // call member function getAverage to calculate student's average; // pass row of grades and the value of tests as the arguments double average = getAverage( grades[ student ], tests ); cout << setw( 9 ) << setprecision( 2 ) << fixed << average << endl; } // end outer for } // end function
average = getAverage (grades[student], tests);
grades is a ten by three 2D array
so passing student which is the first dimension or you may say it the row, will this pass all the colunms (the elements of second dimension array ? )



LinkBack URL
About LinkBacks


