Program to find sum of elements in each row and each column of the given matrix and print the greatest of the same

Program to find sum of elements in each row and each column of the given matrix and print the greatest of the same

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.

Program to find sum of elements in each row and each column of the given matrix and print the greatest of the same


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.

Algorithm to find the sum of elements in each row and each column of the given matrix

  • Input the number of rows and columns of the matrix.
  • Input the matrix elements.
  • Traverse the matrix find the sum of each row and each column and display them.
  • Find the row having the greatest sum and display it.
  • Find the column having the greatest sum and display it.


face prep pro ad bannerClick here to learn more about FACE Prep PRO


Program to find the sum of elements in each row and each column of the given matrix and print the greatest of the sam

@@coding::1@@



Recommended Programs



Program to find sum of elements in each row and each column of the given matrix and print the greatest of the same

c