Code not working

my code is giving infinite 1s
my code is
#include
using namespace std;
int main(){
int n;
cin>>n;
int row=1;
while(row<=n){
int 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;

}row=row+1;
return 0;

}

Hey @kush2103

#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int row=1;
	while(row<=n){
		int 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;//this was also outside else 
		}
		cout<<endl;//added this for line break
		row=row+1;//this was presnet outside loop
	}
	return 0;
}

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.