Given a square matrix, calculate the absolute difference between the sums of its diagonals.

Calculate absolute diffrence between of diagonals of square Matrix

Given a square matrix, calculate 
the absolute difference between the sums of its diagonals.

For example, the square matrix array  is shown below:

    1 2 3
    4 5 6
    9 8 9  

The Sum left-to-right diagonal = 1+5+9=15
The Sum right to left diagonal = 3+5+9=17

Their absolute difference is = |17-15| =2

Coding

Previous Post Next Post