In this program, we are taking a matrix of size 3x3 defined using #define ROW and COL. Here we are initializing the matrix in order to keep the program brief. Then we are accessing the matrix using 2 loops for rows and columns.
Inside the loop, we are checking if the row index is greater than equal to the column index. For our lower diagonal, the row index will always be greater than equal to the column index and thus the elements are written as it is. While the condition is not satisfied, the elements are replaced by 0.
Program to print lower triangle of a square matrix in C
Output
In this program, we are taking a matrix of size 3x3 defined using #define ROW and COL. Here we are initializing the matrix in order to keep the program brief. Then we are accessing the matrix using 2 loops for rows and columns.
Inside the loop, we are checking if the row index is greater than equal to the column index. For our lower diagonal, the row index will always be greater than equal to the column index and thus the elements are written as it is. While the condition is not satisfied, the elements are replaced by 0.
need an explanation for this answer? contact us directly to get an explanation for this answer