How to resolve the algorithm Sum of elements below main diagonal of matrix step by step in the PL/I programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sum of elements below main diagonal of matrix step by step in the PL/I programming language

Table of Contents

Problem Statement

Find and display the sum of elements that are below the main diagonal of a matrix. The matrix should be a square matrix.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Sum of elements below main diagonal of matrix step by step in the PL/I programming language

Source code in the pl/i programming language

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;

  

You may also check:How to resolve the algorithm Doubly-linked list/Traversal step by step in the PL/I programming language
You may also check:How to resolve the algorithm Variadic function step by step in the PL/I programming language
You may also check:How to resolve the algorithm Hamming numbers step by step in the PL/I programming language
You may also check:How to resolve the algorithm Fast Fourier transform step by step in the PL/I programming language
You may also check:How to resolve the algorithm Mutual recursion step by step in the PL/I programming language