// Program to sum up each row of the array // and output the sum of each row... // Extend this to find the maximum row sum // in this 2D array #include #define MAX_ROW 3 #define MAX_COL 3 int main(void) { // Declare and initialise an array int array[MAX_ROW][MAX_COL] = {{-17, -12, -13}, {-4, -5, -6}, {-7, -8, -9}}; int max; int sum_row = 0; // Let's do some stuff here! for (int i = 0; i < MAX_ROW; i++) { sum_row = 0; for (int j = 0; j < MAX_COL; j++) { sum_row = sum_row + array[i][j]; if (i == 0) { max = sum_row; } } printf("The sum of the row is %d\n", sum_row); //clearmax = sum_row; if (sum_row > max || i == 0) { max = sum_row; } } printf("The max row sum is %d\n", max); return 0; }