before inputting col and is wrong please tell me how I can do after while loop only I am able to write int col=1; otherwise its giving me wrong ans
Manmohan loves pattern 1
please explain me I won’t be able to understand
int main()
{
int n;
cin>>n;
int row=1, col;
while(row<=n){
col=1;
if(row%2!=0){
while(col<=row){
cout<<1;
col=col+1;
}
}
else{
cout<<1;
while(col<=row-2){
cout<<0;
col=col+1;
}
cout<<1;
}
cout<<endl;
row=row+1;
}
return 0;
}
I have declared col outside while loop here. Check it.