C++ Program to Find Sum of Diagonals of Matrix

Here is the C++ program to find the sum of diagonals of a matrix.

The matrix should be a square matrix.

 

Output

Enter size of the square matrix(max 5):

3

1 2 3

4 5 6

7 8 9

Sum of 1st diagonal is 15

Sum of 2nd diagonal is 15

Leave a Reply

Your email address will not be published. Required fields are marked *