// Program to decide whether the matrix is a // lower triangular matrix. /* A square matrix where all elements above the main diagonal are zero is called a lower triangular matrix. Eg.: c0 c1 c2 r0 2 0 0 r1 1 5 0 r2 1 -1 -2 */ #include #define MAX_ROW 3 #define MAX_COL 3 int is_lower_tri(int array[MAX_ROW][MAX_COL]); int main(void) { int array[MAX_ROW][MAX_COL] = {{2, 0, 0}, {1, 5, 0}, {1, -1, -2}}; if (is_lower_tri(array)) { printf("The matrix is a lower triangular matrix\n"); } else { printf("The matrix is NOT a lower triangilar matrix\n"); } return 0; } int is_lower_tri(int array[MAX_ROW][MAX_COL]) { int is_lower = 1 ; for(int i = 0; i < MAX_ROW; i++) { for(int j = 0; j < MAX_COL; j++) { if(j > i && array[i][j] != 0) { is_lower = 0; } } } return is_lower; }