What is wrong with my code?

#include
using namespace std;
int main() {
int n,m;
cin>>n>>m;
int a[n][m];
int val = 1;
for(int i = 0;i<n;i++)
{
for(int j = 0;j<m;j++)
{
a[i][j] = val;
val++;
}
}
for(int i = 0;i<n;i++)
{
for(int j = 0;j<m;j++)
{
cout<<a[i][j]<<" β€œ;
}
cout<<endl;
}
cout<<endl;
for(int i = 0;i<m;i++)
{
if(i%2 == 0)
{
for(int j = 0;j<n;j++)
{
cout<<a[j][i]<<”, β€œ;
}
}else
{
for(int j = n-1;j>=0;j–)
{
cout<<a[j][i]<<”, ";
}
}
}
cout<<β€œEND”;
return 0;
}

hello @alamsarfraz422
here u have to print in spiral order
like this (in anticlockwise form)->
ss

in ur code u are trying to print it in wave form.

the video is available for this problem pls check