Can yuo me what is wrong with this code

#include<bits/stdc++.h>
using namespace std;
void print(int mat[][100],int n, int m)
{

for(int j=0; j<n; j++)
{
    if(j%2==0)
    {
        for(int i=0; i<n; i++)
        {
            cout<<mat[j][i]<<", ";
            
        }
        //cout<<endl;
    }
    else
    {
        for(int i=m-1; i>=0; i--) //::-- this loop prints out the pattern in the reverse order;
        {
            cout<<mat[j][i]<<", ";
            
        }
        //cout<<endl;
    }
    
}
cout<<"END"<<endl;

}

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

return 0;

}

@WARHEAD
Your code prints wrong outputs in case when the no of rows and columns are not equal.

Input :
3 4
1 2 3 4
5 6 7 8
9 10 11 12

Expected Output :
1, 5, 9, 10, 6, 2, 3, 7, 11, 12, 8, 4, END

Your Output :
1, 4, 7, 11, 8, 5, 2, 3, 6, 9, END

arey but why does it even matter because we just need to keep on printing the elements of the column and then change the column until we reach the end.

@WARHEAD
It clearly matters as you can see in the above testcase. Your code is failing in this testcase and others like these as your approach is quite different. Even for the input , the standard method followed is to take input in a[i][j] where i represents rows and j represents columns. Since you are taking a reversed input , your entire code changes according to it and fails in testcases when no of rows and cols are not equal. Make some corrections regarding these cases.