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

C Program to find the Sum of Upper Triangular Elements 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[20][20];
                  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 

Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share