Program to Display Lower Triangular Matrix.
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int a[20][20],i,j,n;
cout<<"Enter Size of Square Matrix: ";
cin>>n;
cout<<"\nEnter "<<(n*n)<<" Elements of Matrix: ";
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cin>>a[i][j];
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i<j)
a[i][j]=0;
}
}
cout<<"\nLower Triangular Matrix is:\n";
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cout<<a[i][j];
cout<<"\t";
}
cout<<"\n\n";
}
getch();
return 0;
}
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int a[20][20],i,j,n;
cout<<"Enter Size of Square Matrix: ";
cin>>n;
cout<<"\nEnter "<<(n*n)<<" Elements of Matrix: ";
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cin>>a[i][j];
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i<j)
a[i][j]=0;
}
}
cout<<"\nLower Triangular Matrix is:\n";
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cout<<a[i][j];
cout<<"\t";
}
cout<<"\n\n";
}
getch();
return 0;
}