Having doubt in logic used in while loop

for even row, why we are defining while loop like this:

while(col<=row-2);

It says that if we have an odd row , then we need to print all 1’s. Now you can see that in every odd row we have 1’s equal to the row number , so we run a loop inside if to print number of ones equal to row.

Similarly we do it for even rows, print first and last as 1, and in between row-2 number of zeroes with the help of loop