//PROGRAM TO PRINT LOWER TRIANGULAR MATRIX
#include<stdio.h>
void main()
{
int m,n,i,j,a[10][10];
printf("Enter the order of a square matrix: ");
scanf("%d%d",&m,&n);
if(m==n)
{
printf("Enter %d elements in the matrix:\n",m*n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
printf("You have entered the following matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%4d",a[i][j]);
printf("\n");
}
printf("Lower triangular matrix for the given matrix is:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i<j)
a[i][j]=0;
printf("%4d",a[i][j]);
}
printf("\n");
}
}
else
printf("Matrix should be a square matrix,So enter a valid order");
}
#include<stdio.h>
void main()
{
int m,n,i,j,a[10][10];
printf("Enter the order of a square matrix: ");
scanf("%d%d",&m,&n);
if(m==n)
{
printf("Enter %d elements in the matrix:\n",m*n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
printf("You have entered the following matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%4d",a[i][j]);
printf("\n");
}
printf("Lower triangular matrix for the given matrix is:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i<j)
a[i][j]=0;
printf("%4d",a[i][j]);
}
printf("\n");
}
}
else
printf("Matrix should be a square matrix,So enter a valid order");
}