I have a doubt how the even row is getting printed.
In the else statement, the true expression of while is (col<=row-2) how will it print 1001 if row=4
Explain the dry run of else statement
Hey @Tanvi-Varshney-250726472940778,
-
As you have noticed a common pattern in the even rows:
i.e. first and the last col is 1 as rest all the values are 0. -
The number of values or column per row is equal to the row number.
i,e row 1: 1 element
row 2: 2 element
so on…
So, if row is even:
- print 1 for col 0
- (col<=row-2)
This means:
for col 1 to row-2 i.e. the second last column print 0 - print 1 for row-1 col i.e. the last col.
Hope, this would help.
2 Likes
Thnku bhaiya to resolve my doubt
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.