-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQues-19.cpp
44 lines (38 loc) · 932 Bytes
/
Ques-19.cpp
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
/*
QUESTION-19:
Write a program to implement Lower Triangular Matrix using one-dimensional array.
SOLUTION:
*/
#include<iostream>
using namespace std;
void lower(int matrix[3][3], int row, int col)
{
int i, j;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if (i < j)
{
cout << "0" << " ";
}
else
cout << matrix[i][j] << " ";
}
cout << endl;
}
}
// Driver Code
int main()
{
cout << "\n\t ~~~~~~~~~~~~~~~~~~~~~~~Practical 19~~~~~~~~~~~~~~~~~~~~\n\t\t\t\t \n";
int matrix[3][3] = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}};
int row = 3, col = 3;
cout << "Lower triangular matrix: \n";
lower(matrix, row, col);
// cout << "Upper triangular matrix: \n";
// upper(matrix, row, col);
return 0;
}