Check the compiler output, fix the error and try again

#include
using namespace std;

void rotate(int arr[][100],int n)
{
for(int i=0;i<n;i++)
{
int start_row=0;
int end_col=n-1;

	while(start_row < end_col)
	{
		swap(arr[i][start_row],arr[i][end_col]);
		start_row++;
		end_col--;
	}
}
// transpose

for(int i=0;i<n;i++)
{
	for(int j=0;i<n;j++)
	{
		if(i<j)
		{
			swap(arr[i][j],arr[j][i]);
		}
	}
}
// output

for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
		cout<<arr[i][j]<<" ";
	}
	cout<<endl;
}

}
int main()
{
int n;
cin>>n;
int arr[100][100];

for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
		cin>>arr[i][j];
	}
}
rotate(arr,n);


return 0;

}

@shubhamdangwal3 in the second loop of transpose you have written i<n but it should be j<n.
hope its cleared if yes dont forget to hit like and mark resolved otherwise ask me :smiley:

1 Like

Thank you so much sir !

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.