Code:
#include <stdio.h>
#include <stdlib.h>
#define DIM 5
int main()
{
int mat[DIM][DIM] = {0}, row, col, rowSum, colSum;
printf("Enter 25 numbers: ");
for (row = 0; row < DIM; row++)
for (col = 0; col < DIM; col++)
scanf("%d", &mat[row][col]);
printf("\n%d\n", mat[row][col]);
rowSum += mat[row];
colSum += mat[col];
printf("The sum of the rows is: %d", rowSum);
printf("\n");
printf("The sum of the colums is: %d", colSum);
return 0;
}
Here's what happens when I run the program:
Enter 25 numbers: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25
2621304
The sum of the rows is: -594119456
The sum of the colums is: 13106020
Process returned 0 (0x0) execution time : 14.185 s
Press any key to continue.
2621304 is supposed to be the matrix. Ignore the sums; I know they're wrong.