#include <stdio.h>
int main()
{
int a[3][3],i,j,upper_sum=0,lower_sum=0;
printf("Enter elements for the matrix :
");
for(i = 0; i < 3; i++){
for(j = 0; j < 3; j++){
printf("Matrix[%d][%d]:
",i,j);
scanf("%d",&a[i][j]);
}
}
printf("The Matrix:
");
for(i = 0; i < 3; i++){
for(j = 0; j < 3; j++){
printf("%d ",a[i][j]);
}
printf("
");
}
printf("Getting sum...
");
for(i = 0; i < 3; i++){
for(j = 0; j < 3; j++){
if(i < j){
printf("The Upper Triangle elements are %d
",a[i][j]);
upper_sum+=a[i][j];
}
if(i > j){
printf("The lower Triangle elements are %d
",a[i][j]);
lower_sum+=a[i][j];
}
}
}
printf("Sum of Uppper triangles are : %d
",upper_sum);
printf("Sum of lower triangles are : %d
",lower_sum);
return 0;
}