Code showing /bin/run.sh: line 4: 22 Segmentation fault (core dumped) ./exe error

#include
using namespace std;
void spiralprint(int a[][100],int n , int m){
int sc = 0;
int ec = m -1 ;
int sr = 0 ;
int er = n-1;
while(sr<er && sc<ec){
for (int i = sc; sc<ec ; i ++ ){
cout<<a[sr][i]<<", β€œ;
}
sr++;
for (int j = sr ; sr<er ; j ++ ){
cout<<a[j][ec]<<”, β€œ;
}
ec–;
for (int k = ec ; k>sc ; k++){
cout<<a[er][k]<<”, β€œ;
}
er–;
if (sr<er){
for (int t = 0 ; t >sr ; t++){
cout<<a[t][sc]<<”, ";
sc++;
}
}
}
cout<<β€œEND”;
}

int main() {
int n , m , x ;
cin >> n >> m ;
if (n < 1 || n > 10 || m < 1 || m > 10){
return -1;
}
int a[n][100];
for ( int i = 0 ; i < n ; i++ ){
for ( int j = 0 ; j < m ; j++ ){
cin>>x;
a[i][j] = x;
}
}
spiralprint(a,n,m);
return 0;
}
How can I fix this error?

hi @prakhardotdhyani_bcf48b5fdec42d8e
refer

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.