Dry run of Pattern problem

I’m unable to understand the Dry run for the pattern problem in which we have to print 1 in odd rows and first and last number will be printed 1 and zeros in middle for even rows

hello @shazanahmed1
u r approach is correct , if row number is odd then u need to print all 1, otherwise if even then u need to print first and last column as 1 and remaining all should be 0.

for example let say n=5
odd…row1 -> 1
even row2 -> 1 1
odd row3 -> 1 1 1
even row4 -> 1 0 0 1
odd row5 -> 1 1 1 1 1

I understood how pattern is getting printed for the odd and even numbered rows , but I’m unbale to understand how the Row value and column values get updated in the loop execution process.

for row = 1 to N
      if row is odd
           print 1 row times    
       else 
         print 1 and then print 0 row-2 times and then again print 1

this is how updation is happening

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.