#include<stdio.h>
int main()
{
int i,j,p,q,a[10][10];
printf("\nEnter the order of the matrix \n\n");
scanf("%d",&p);
printf("\nEnter the %d elements of the matrix \n\n", p*p);
for(i = 0; i< p; i++)
{
for(j = 0; j<p ; j++)
{
scanf("%d", &a[i][j]);
}
}
printf("\nThe matrix is \n\n");
for(i = 0; i< p; i++)
{
for(j = 0; j<p ; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
for(i = 0; i< p; i++)
{
for(j = 0; j<p ; j++)
{
if(i<=j)
{
a[i][j]=0;
}
}
}
printf("\nThe lower triangular matrix is \n\n");
for(i = 0; i< p; i++)
{
for(j = 0; j<p ; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter the order of the matrix 3 Enter the 9 elements of the matrix 1 2 3 4 5 6 7 8 9 The matrix is 1 2 3 4 5 6 7 8 9 The lower triangular matrix is 0 0 0 4 0 0 7 8 0