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]] 



 
trap: procedure options (main);      /* 17 December 2021 */
   declare n fixed binary;
   get (n);
   put ('The order of the matrix is ' || trim(n));
   begin;
      declare A (n,n) fixed binary;
      declare sum fixed binary;
      declare (i, j) fixed binary;
 
      get (A);
      sum = 0;
      do i = 2 to n;
         do j = 1 to i-1;
            sum = sum + a(i,j);
         end;
      end;
      put edit (A) (skip, (n) f(4) );
      put skip data (sum);
   end;
end trap;
 