The program to find the sum of elements in each row and each column of the given matrix and print the greatest of the same is discussed here. Input the matrix find the sum of each row and each column and display the row having the greatest sum and also the column having the greatest sum.
For example, consider the matrix
mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
Sum of row 1 = 1 + 2 + 3 = 6
Sum of row 2 = 4 + 5 + 6 = 15
Sum of row 3 = 7 + 8 + 9 = 24
Row 3 has the greatest sum.
Sum of column 1 = 1 + 4 + 7 = 12
Sum of column 2 = 2 + 5 + 8 = 15
Sum of column 3 = 3 + 6 + 9 = 18
Column 3 has the greatest sum.
@@coding::1@@
Recommended Programs