I'm having major problems figuring out this homework problem.
Write a program that finds the maximum and minimum of elements of a two dimensional array using a function that has a 2D array in its parameter list.
Any help would be greatly appreciated.
insertCode:/* Chapter 9 Problem 9 */ #include <stdio.h> double find_max(double [][5], int n); double find_min(double [][5], int n); int main(void) { int n; double a[][5] = {2, 7, 6, 8, 4}; int max, min; find_max(a[][5], 2); find_min(a[][5], 2); printf("Max: %d\nMin: %d", max, min); return 0; } double find_max(double a[][5], int m) { int i,j; int max = a[0][0]; for(i = 0; i < 2; i++) for(j = 0; j < 5; j++) if(a[i][j] > max) { max = a[i][j]; } return max; } double min(double a[][5], int m) { int i,j; int min = a[0][0]; for(i = 0; i < 2; i++) for(j = 0; j < 5; j++) if(a[i][j] < min) { min = a[i][j]; } return min; }



LinkBack URL
About LinkBacks





