Pattern problem

How we will code this pattern using for loop

hello @guptakanwal30,
first you need to observe the pattern.
observations
a) ith row will have i number of digits.
b) if row no (i,e i) is odd then all digits in that row will be 1.
c) if row no (i,e i) is even then only first and last digits in that row will be 1 and all other digits will be 0.

now try to code on ur own. if u stuck then feel free to ask.

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.