Spiral print anticlockwise

#include
using namespace std;
int spiralprint(int a[][100],int m,int n)
{
int start_row=0,start_col=0,end_row=m-1,end_col=n-1,i;
while(start_row<=end_row&&start_col<=end_col)
{
for(i=start_col;i<=end_col;i++)
{
cout<<a[start_row][i]<<", β€œ;
}
start_row++;
for(i=start_row;i<=end_row;i++)
{
cout<<a[i][end_col]<<”, ";
}
end_col–;

if(end_row>start_row)
{
 for(i=end_col;i>=start_col;i--)
{
   cout<<a[end_row][i]<<", ";
}
end_row--;
}
if(end_col>start_col)
{
 for(i=end_row;i>=start_row;i--)
{
    cout<<a[i][start_col]<<", ";
}
start_col++;
}
}

cout<<β€œEND”;
return 0;
}

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

spiralprint(a,m,n);



return 0;

}

//my test case not running please tell the error

why you have done this

firstly i have transposed the array and then i rotate it clockwise
and my anser is correct but test case not running

send the link of code
save it to https://ide.codingblocks.com/
and the share genrated link

this is the link tell me the problem

the problem is

this willl only work when n==m for square matrix
you can take any example where n not equal to m your code will give wrong output

for ex
3 4
1 2 3 4
5 6 7 8
9 10 11 12

try for this