Solving on hacker blocks i(setting up c++ environment)

please explain the conditions of while loop which is inside the if and else …

please explain the logic how it is printing

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

sir i am asking about the condition which is used in the while loop … please reply ASAP

@Devwrat Sahu sir please solve my doubt and give a proper explanation of that answer

I don’t really know what you are finding confusing, but I’ll try to explain.
Any row ‘i’ has i characters.
So because we want to print n rows, so outer loop runs until row<=n.

Now if its an odd row, it has all 1’s. So we print all 1’s if ‘row’ is odd, or row%2==1.
If its an even row, we print the first the first and last character as 1 and all other’s as zeros.