Program to print the sum of boundary elements of a matrix | faceprep

Program to print the sum of boundary elements of a matrix | faceprep

Program to print the sum of boundary elements of a matrix is discussed here. Given a matrix, the task is to print the boundary elements of the matrix and display their sum.

Program to print the sum of boundary elements of a matrix


For example, consider the matrix given below.

1 2 3

4 5 6

7 8 9


Boundary Matrix

1 2 3n4   6n7 8 9n

Sum of boundary elements: 1 + 2 + 3 + 4 + 6 + 7 + 8 + 9 = 40

Algorithm to print the sum of boundary elements of a matrix

  • Input the order of the matrix.
  • Input the matrix elements.
  • Print all the boundary elements of the matrix.
  • Find the sum of the boundary elements.
  • Print sum.


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


Program to print the sum of boundary elements of a matrix

@@coding::1@@


Recommended Programs


Program to print the sum of boundary elements of a matrix

c