Given N, help Manmohan to print pattern upto N lines. For eg For N=6 , following pattern will be printed.
1
11
111
1001
11111
100001
Given N, help Manmohan to print pattern upto N lines. For eg For N=6 , following pattern will be printed.
1
11
111
1001
11111
100001
Hey @dipeshpandey2001 do you want code or approach of this problem?
You just have to check
if(current_row%2!=0)
{
cout<<"1";
}
else{
if(current_col==i || current_col ==1)
cout<<"1";
else
{
cout<<"0";
}
}
can i get the approach also,am not able to understand the logic.
understood the code.
In the given pattern for every odd number row print 1, odd number of times and for every even number row ,print first and last character as 1 and rest of middle characters as 0 .
It has comments too, you can refer this
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.