/*PROGRAM TO PRINT ELEMENTS OF UPPER TRIANGULAR MATRIX*/
#include<conio.h>
#include<iostream.h>
class upper_triangular
{
int m,n,i,j,a[10][10];
public:
void input();
void output();
};
void upper_triangular::input()
{
cout<<“Enter order of the matrrix: “;
cin>>m>>n;
if(m==n)
{
cout<<“Enter “<<m*n<<” elements in the matrix:\n”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cin>>a[i][j];
}
output();
}
else
cout<<“Matrix must be a square matrix”;
}
void upper_triangular::output()
{
cout<<“Given matrix is:\n”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cout<<a[i][j]<<” “;
cout<<endl;
}
cout<<“Given matrix in upper triangular form is:\n”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i<=j)
cout<<a[i][j]<<” “;
else
cout<<“0″<<” “;
}
cout<<endl;
}
}
void main()
{
upper_triangular ut1;
clrscr();
ut1.input();
getch();
}