Check The Programming Section
Consider an example of 4 X 4 matrix
1 2 3 4
5 6 7 8
9 0 11 12
13 14 15 16
Then the lower right triangle will be
4
7 8
0 11 12
13 14 15 16
A lower right triangular matrix will print the values of following locations
[0,3]
[1,2] [1,3]
[2,1] [2,2] [2,3]
[3,0] [3,1] [3,2] [3,3]
At first row we need to print 1 item and in 2nd row 2 items and so on. So, in the code we have used one condition at line 34 if(col-j<=i+1), which will check the index of the column that we need to print.
At First Iteration
i = 0 and j = 0 to 3<4 and incremented by 1 and number of col is 4
j = 0, col-0<=1, false
j = 1, col-1<=1, false
j = 2, col-2<=1, false
j = 3, col-3<=1, true print mat of [0][3]
At Second Iteration
i = 1 and j = 0 to 3<4 and incremented by 1 and number of col is 4
j = 0, col-0<=2, false
j = 1, col-1<=2, false
j = 2, col-2<=2, true print mat of [1][2]
j = 3, col-3<=2, true print mat of [1][3]
At Third Iteration
i = 2 and j = 0 to 3<4 and incremented by 1 and number of col is 4
j = 0, col-0<=3, false
j = 1, col-1<=3, true print mat of [2][1]
j = 2, col-2<=3, true print mat of [2][2]
j = 3, col-3<=3, true print mat of [2][3]
At last Iteration
i = 3 and j = 0 to 3<4 and incremented by 1 and number of col is 4
j = 0, col-0<=4, true print mat of [3][0]
j = 1, col-1<=4, true print mat of [3][1]
j = 2, col-2<=4, true print mat of [3][2]
j = 3, col-3<=4, true print mat of [3][3]