Task

Find and display the sum of elements that are below the main diagonal of a matrix.

The matrix should be a square matrix.



 ───   Matrix to be used:   ───


     [[1,3,7,8,10],
      [2,4,16,14,4],
      [3,1,9,18,11],
      [12,14,17,18,20],
      [7,1,3,9,5]] 



$ include "seed7_05.s7i";
 
const proc: main is func
  local
    var integer: sum is 0;
    var integer: i is 0;
    var integer: j is 0;
    const array array integer: m is [] ([] ( 1,  3,  7,  8, 10),
                                        [] ( 2,  4, 16, 14,  4),
                                        [] ( 3,  1,  9, 18, 11),
                                        [] (12, 14, 17, 18, 20),
                                        [] ( 7,  1,  3,  9,  5));
  begin
    for i range 2 to length(m) do
      for j range 1 to i - 1 do
        sum +:= m[i][j];
      end for;
    end for;
    writeln(sum);
  end func;