-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlowertriangular.c
More file actions
50 lines (45 loc) · 1.01 KB
/
lowertriangular.c
File metadata and controls
50 lines (45 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// C program to find lower triangular matrix
#include <stdio.h>
#define MAX_ROWS 3
#define MAX_COLS 3
int main()
{
int array[MAX_ROWS][MAX_COLS];
int row, col, isLower;
printf("Enter elements in matrix of size %dx%d: \n", MAX_ROWS, MAX_COLS);
for(row=0; row<MAX_ROWS; row++)
{
for(col=0; col<MAX_COLS; col++)
{
scanf("%d", &array[row][col]);
}
}
isLower = 1;
for(row=0; row<MAX_ROWS; row++)
{
for(col=0; col<MAX_COLS; col++)
{
if(col>row && array[row][col]!=0)
{
isLower = 0;
}
}
}
if(isLower == 1)
{
printf("\nMatrix is Lower triangular matrix: \n");
for(row=0; row<MAX_ROWS; row++)
{
for(col=0; col<MAX_COLS; col++)
{
printf("%d ", array[row][col]);
}
printf("\n");
}
}
else
{
printf("\nMatrix is not a Lower triangular matrix");
}
return 0;
}