# C Program to find the Sum of Upper Triangular Elementsof Matrix

## C Program to find the Sum of UpperTriangularElements of Matrix

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

### Sum of Upper Triangular Elements of Matrix Program

#include<stdio.h>
int main(){
int M;
int m, n, i, j, sum=0;
printf("\nEnter the Row and Column sizes of Matrix : ");
scanf("%d %d", &m, &n);
printf("\n\n Enter the Matrix elements one by one \n");
for (i = 1; i<=m; i++)
for (j = 1; j<=n; j++)
scanf("%d", &M[i][j]);
printf("\n The Given Matrix is : \n\n");
for (i = 1; i<=m; i++){
for (j = 1; j<=n; j++)
printf("\t%d ", M[i][j]);
printf("\n\n");
}
for (i = 1; i<=m; i++){
for (j = 1; j<=n; j++)
if(i<j)
sum=sum+M[i][j];
}
printf("\n\n The Sum of Upper Triangular elements of Matrix is %d", sum);
return(0);
}

Sample Output:

Enter the Row and Column sizes of Matrix : 3    3

Enter the Matrix elements one by one
4
2
3
5
6
7
9
1
8

The Given Matrix is :

4       2       3

5       6       7

9      1       8

The Sum of Upper Triangular elements of Matrix is 12

Related Popular Posts:

*  Write a c program to check whether a given number is prime number or not?

*  Write a C program to find the prime numbers between 1 and 100

*  Write a C program to display the prime numbers between a range ?

*  Write a C program to find the prime numbers between a range using while loop?

*  Write a C program to find the sum of prime numbers between a range