Array wave print column wise

#include<bits/stdc++.h>
using namespace std;
int main() {

int r,c;
cin>>r>>c;
int a[r][c];
for(int i=0;i<r;i++)
{
	for(int j=0;j<c;j++)
	{
		cin>>a[i][j];
	}
}

for(int i=0;i<c;i++)
{
	if((i%2)==0)
	{
		for(int j=0;j<r;j++)
		{
			cout<<a[j][i]<<' ';
		}
	}
	else
	{
		for(int j=r-1;j>=0;j--)
		{
			cout<<a[j][i]<<' ';
		}
	}
}
cout<<"end"<<endl;
return 0;

}

here is my code it giving right output in my ide but wrong in coding blocks ide

@tusharjha9835 your output should strictly match the given output like i think in given there are commas too and end is capital