forked from kushalsingh-00/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
matrix5.c
35 lines (33 loc) · 832 Bytes
/
matrix5.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
-------------------------------------------------------
Name : Matrix
Author : Kushal Singh Rathore
Discription : Sum Of Upper & Lower Triangle
-------------------------------------------------------
*/
#include<stdio.h>
int main()
{
int a[100][100],b,c,sum_upper=0,sum_lower=0;
printf("Enter the no of rows and column\n");
scanf("%d %d",&b,&c);
printf("Enter the elements\n");
for(int i=0;i<b;i++)
{
for (int j = 0; j < c; j++)
{
scanf("%d",&a[i][j]);
}
}
for(int i=0;i<b;i++)
{
for (int j = 0; j < c; j++)
{
if(i<j)
sum_upper+=a[i][j];
else if(i>j)
sum_lower+=a[i][j];
}
}
printf("sum of upper and lower triangle is\n%d\n%d",sum_upper,sum_lower);
}