Explore
ProGrad Programs
Placement Prep
TCS Codevita
Live Placement Training
Webinars
About Us

Edit
Reply




Edit

Program to print the sum of boundary elements of a matrix | FACE Prep

Published on 11 Mar 2020

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.


For example, consider the matrix given below.


1 2 3

4 5 6

7 8 9


Boundary Matrix


1 2 3
4   6
7 8 9


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.


Program to print the sum of boundary elements of a matrix


C
C++
Java
Python 3

Output
Enter the order of the matrix : 3 3
Input the matrix elements :
1 2 3
4 5 6
7 8 9
Boundary Matrix :
1 2 3
4   6
7 8 9
Sum of boundary is 40


Recommended Programs







If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in