Why it show wrong answer....!

In my dev c++ compiler, it shows the same output. why it shows wrong here.

here is my code.

int main()
{
int a,b, arr[100][100];
cin>>a>>b;

for(int i=0; i<a; i++){
	for(int j=0; j<b; j++){
		cin>>arr[i][j];
	}
}

for(int j=0; j<a; j++){
	if(j%2==0)
	{
	     for(int i=0; i<b; i++)
		 cout<<arr[i][j]<<" ";	
	}
	else
	{
		 for(int i=b-1; i>=0; i--)
		 cout<<arr[i][j]<<" ";	
	}
}
cout<<"END";

}

@sonu28sharma99 your j should be iterating over column (b) and i should be iterating over rows (a). otherwise it will give you wrong answer for case where rows and column are not equal.

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.