#include<iostream>
using namespace std;
int main()
{
int n, m, i, j, s, c;
s = c = 0;
cout << "Enter Array Row & Column Number : ";
cin >> n >> m;
cout << endl;
int a[n][m];
cout << "Enter Array Element :: \n";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cin >> a[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(i<j)
{
s = s + a[i][j];
}
if(i>j)
{
c = c + a[i][j];
}
}
}
cout << "Sum of Upper Triangle Element Of Matrix :: " << s << endl;
cout << "Sum of Lower Triangle Element Of Matrix :: " << c << endl;
return 0;
}
using namespace std;
int main()
{
int n, m, i, j, s, c;
s = c = 0;
cout << "Enter Array Row & Column Number : ";
cin >> n >> m;
cout << endl;
int a[n][m];
cout << "Enter Array Element :: \n";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cin >> a[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(i<j)
{
s = s + a[i][j];
}
if(i>j)
{
c = c + a[i][j];
}
}
}
cout << "Sum of Upper Triangle Element Of Matrix :: " << s << endl;
cout << "Sum of Lower Triangle Element Of Matrix :: " << c << endl;
return 0;
}
Comments
Post a Comment