Write a C program to print lower triangle of a square matrix.
For example the output of a given matrix
2 3 4 will be 2 0 0
5 6 7 5 6 0
4 5 6 4 5 6
Answers
what is that can u explain
int main()
{
int matrix[20][20];
int i,j,r;
scanf("%d", &r); //Accepts number of rows or columns
for(i=0;i< r;i++) //Accepts the matrix elements from the test case data
{
for(j=0;j {
scanf("%d",&matrix[i][j]);
}
}
Lower triangular matrix is a matrix which contain elements below principle diagonal including principle diagonal elements and rest of the elements are 0.
Upper triangular matrix is a matrix which contain elements above principle diagonal including principle diagonal elements and rest of the elements are 0.
LOWER TRIANGULAR :
{\displaystyle \begin{bmatrix} A_{00} & 0 & 0 & ... & 0\\ A_{10} & A_{11} & 0 & ... & 0\\ A_{20} & A_{21} & A_{22} & ... & 0\\ . & . & . & . & .\\ . & & & & \\ . & & & & \\ . & & & & \\ . & & & & \\ . & & & & \\ A_{row0} & A_{row1} & A_{row2} & ... & A_{rowcol} \end{bmatrix}}
UPPER TIRANGULAR :
{\displaystyle \begin{bmatrix} A_{00} & A_{01} & A_{02} & ... & A_{0col}\\ 0 & A_{11} & A_{22} & ... & A_{1col}\\ 0 & 0 & A_{22} & ... & A_{2col}\\ . & . & . & . & .\\ . & & & & \\ . & & & & \\ . & & & & \\ . & & & & \\ . & & & & \\ 0 & 0 & 0 & ... & A_{rowcol} \end{bmatrix}}