C Program to find the Sum of the Lower Triangular Elements of Matrix

This page has a C Program to find the Sum of Lower Triangular Elements of Matrix. It is clear that, this C program will find the Sum of the Lower Triangular Elements of Matrix. The program is used to find the sum of the elements below the principal diagonal and the matrix elements below the principal diagonal are called Lower Triangular Elements of Matrix. The below given C program will find the Sum of Lower Triangular Elements of Matrix. Kindly check out the program to display the Sum of Lower Triangular Elements of Matrix.

Sum of Lower Triangular Elements of Matrix Program

#include<stdio.h>

int main(){

int M[20][20];

int m, n, i, j, sum=0;

printf("

Enter the Row and Column sizes of Matrix : ");

scanf("%d %d", &m, &n);

printf("



Enter the Matrix elements one by one

");

for (i = 1; i<=m; i++)

for (j = 1; j<=n; j++)

scanf("%d", &M[i][j]);

printf("

The Given Matrix is :



");

for (i = 1; i<=m; i++){

for (j = 1; j<=n; j++)

printf("\t%d ", M[i][j]);

printf("



");

}

for (i = 1; i<=m; i++){

for (j = 1; j<=n; j++)

if(i>j)

sum=sum+M[i][j];

}

printf("

The Sum of Lower Triangular elements of Matrix is %d", sum);

return(0);

} Sample Output:

Enter the Row and Column sizes of Matrix : 4 4



Enter the Matrix elements one by one

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16



The Given Matrix is :



1 2 3 4



5 6 7 8



9 10 11 12



13 14 15 16



The Sum of Lower Triagular elements of Matrix is 66

Related Popular Posts: