Segmentation fault

#include
using namespace std;
int main() {
int m,n,k;
cin>>m>>n;
int a[1000][1000]={0};
int row,col;
for (row=0;row<m;row++){
for (col=0;col<n;col++){
cin>>a[row][col];
}
}
int start_col=0;
int start_row=0;
int end_col=n-1;
int end_row=m-1;

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

return 0;

}

this code is giving segmentatuon fault

hello @pranaynigam
pls savr ur code at cb ide and share its link with me

check now->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.