Output is correct why is it not passing test cases, I have used method taught in course videos

#include
using namespace std;

void rotateimage(int a[100][100],int n)
{
int i,x=0,y=n-1,j;

//reversing rows
for(i=0;i<n;i++)
{
	while(x<y)
	{
		swap(a[i][x],a[i][y]);
		x++;
		y--;
	}

		
}

//taking transpose
for(i=0;i<n;i++)
{
	for(j=0;j<n;j++)
	{
		if(j<i)
			swap(a[i][j],a[j][i]);
	}
}

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

}

int main() {
int n,a[100][100],i,j;
cin>>n;
if(n<100)
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cin>>a[i][j];
}

	rotateimage(a,n);

}

return 0;

}

Modified code

here while reversing the rows you have to reinitialise x and y

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.

ok i have given my feedback, thanks a lot

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.