# include # include // // Here we "declare" the functions MATRIX_MIN() and MATRIX_PRINT(): // double matrix_min ( int m, int n, double a[m][n] ); void matrix_print ( int m, int n, double a[m][n] ); int main ( ) { double a[4][3]; int i; int j; int m = 4; int n = 3; int seed; // // Here, we use TIME to get a different seed each time we run the program. // seed = time ( 0 ); srand ( seed ); // // Fill the array with random values. // for ( i = 0; i < m; i++ ) { for ( j = 0; j < n; j++ ) { a[i][j] = ( double ) rand ( ) / ( double ) RAND_MAX; } } // // Print the array using a function. // matrix_print ( m, n, a ); // // Determine the minimum entry. // printf ( "\n" ); printf ( " Minimum matrix entry is %g\n", matrix_min ( m, n, a ) ); return 0; } double matrix_min ( int m, int n, double a[m][n] ) { int i; int j; double value; value = a[0][0]; for ( i = 0; i < m; i++ ) { for ( j = 0; j < n; j++ ) { if ( a[i][j] < value ) { value = a[i][j]; } } } return value; } void matrix_print ( int m, int n, double a[m][n] ) { int i; int j; for ( i = 0; i < m; i++ ) { for ( j = 0; j < n; j++ ) { printf ( " %10g", a[i][j] ); } printf ( "\n" ); } return; }