C Program to add the element of upper triangle in a matrix - With Output

#include<stdio.h>
#include<conio.h>

void main()
{
int a[10][10],i,j,sum=0,size=3;
printf(“Enter the elements of the matrix\n”);

for(i=0;i<size;++i)
{
for(j=0;j<size;++j)
{
scanf(“%d”,&a[i][j]);

if(i<j)
sum=sum+a[i][j];
}
}

printf(“Sum of element of upper triangle is  : %d”,sum);

getch();
}

OUTPUT  :
Enter the element of the matrix
1
2
3
4
5
6
7
8
9

Sum of element of upper triangle is : 11
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment