1 and 0 pattern program

please explain me the program after first for loop in second for loop I won’t be able to understand help me please explain me in detail

like in 3rd line first will be printed 0 after that 1 nd after that 0 how please explain me in detail

how val=1-val work I won’t be able to understand

@tarshid7
val contains only value 0 or 1 which we need to print.
first for loop will run till number of rows we have to print.
if row is odd starting value will be 0 else if row is even starting value will be 1 (val = (row_number%2==0)?1:0).
2nd for loop runs till number of column we have to print for every row.
first we print val and change it to 1 if it is 0 else change it to 0 if it is 1.
if previous val =0 , next val = 1-val = 1,
if previous val = 1, next val = 1-val = 0 and so on.

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.