Printing pattern 1 , 11 , 111 , 1001 , 11111 , 100001

#include

using namespace std;

int main()
{

int n ;
cin>>n;

int row = 1;
int col = 1;

while(row<=n){
if(row % 2 == 0)
{
//even row
cout<<1;

        while(col<=row-2){
            cout<<0;
            col = col +1 ;
        }
        cout<<1;
    }
    else{
         while(col<=row){
       cout<<1 ;
       col=col+1;
       }
        
    }
    row = row+1;
    cout<<endl;
   }

return 0;
}

Hey @sp_wizard
declare int col=1 inside the while loop so that it restarts with every row
if this solves your doubt ,please mark your doubt as resolved :slight_smile: