Sir I am not able to understand what is wrong in the below code for rotate image (N X N array)

//Image Rotation
//rotating the matrix clockwise by 90 degrees
//First taking the transpose of the matrix then exchanging the rows

#include
using namespace std;
int main()
{
int i,j;
int rows,column,k;
int a[100][100];

cin>>k;

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


for(i=0;i<k;i++)
{
    int temp;
    temp = a[i][0];
    a[i][0] = a[i][k-1];
    a[i][k-1]=temp;
}

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



return 0;

}

@harshulgarg21 According to the question, you have to rotate in anti clock wise direction. Also note that the constraints are N < 1000 and you have restricted your array to 100 x 100.

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.