Segmentation fault error

#include
using namespace std;
int main() {
int N,M;
cin>>M>>N;
int a[M][N];
for(int i=0;i<M;i++)
{
for(int j=0;j<N;j++)
{
cin>>a[i][j];
}
}
int dir = 0;

for(int j=0;j<N;j++)
{
if(dir==0)
{
	for(int i=0;i<M;i++)
	{
		cout<<a[i][j]<<" ";
	}
	dir = 1;
	
}

else
{
	for(int i=M-1;i>=0;i--)
	{
		cout<<a[i][j]<<" ";
	}
	dir = 0;
}

}

cout<<"END"<<endl;

}

// Sir , why i am getting error message as
/bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

hello @captian_n3m01
r u trying to compile ur code without giving any input.
if so then first give input in input section and then compile.

if ur issue still persists then pls share ur code using cb ide