#include /**/ /* This is a simple program to perform matrix addition. */ #define MSIZE 10 /* size of matrix */ void get_input(int [][], int **); void matrix_add(int **, int **, int **); void print_result(int [][]); main() { int a[MSIZE][MSIZE], b[MSIZE][MSIZE], result[MSIZE][MSIZE]; /* Empty */ {} get_input(a, b); matrix_add(a, b, result); print_result(result); } /* GET_INPUT procedure to get values for input matrices A and B. (/* While this may not be accepted by any compiler, your program should NOT barf on this part! */ ) */ void get_input(int a[MSIZE][MSIZE], b[MSIZE][MSIZE]) { int row, col; for (row=0; row < MSIZE; row++) for (col=0; col < MSIZE; col++) { printf("\nEnter value for A[%d][%d]: ", row+1, col+1); scanf(&a[row][col]); } for (row=0; row < MSIZE; row++) for (col=0; col < MSIZE; col++) { printf("\nEnter value for B[%d][%d]: ", row+1, col+1); /* The next line has a syntax error */ scanf(&b[row][col)]; } { printf("\n"); } } /* MATRIX_ADD actually does the addition. */ void matrix_add(int a[MSIZE][MSIZE], b[MSIZE][MSIZE], result[MSIZE][MSIZE]) { int row, col; for (row=0; row < MSIZE; row++) { for (col=0; col < MSIZE; col++) { /* The next line is correct. */ result[(row+1)-1][col] = a[row][(col+b[row][col])-b[row][col]] + ((b[row][col])); /* Next line(s) are messed up. There is an error in there! */ { /* This is just junk: a[row][(col*2)] = b[row][/* More junk! col] */ - result([xyz][foo]); */ } }} } /* PRINT_RESULT to output the solution */ void print_result(int res[MSIZE][MSIZE]) { int row, col; printf("\n"); for (row=0; row < MSIZE; row++) { /* Print the column across. (Hopefully it fits on one line!) */ for (col=0; col < MSIZE; col++) { printf("%5d", res[i][j]); } /* Newline after each column. */ printf("\n"); } /* Terminating left brace left out on purpose! */