Output giving garbage values

#include
using namespace std;

int main(){
int M;
int N;

cin>>M;
cin>>N;

int arr[M][N];

for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
        cin>>arr[M][N];
    }
}

int row_start=0;
int col_start=0;
int row_end=M-1;
int col_end=N-1;

while(row_start<=row_end && col_start<=col_end){

// for printing col start

for(int row=row_start;row<=row_end;row++){
cout<<arr[row][col_start]<<" β€œ<<”,";
}
col_start++;
// for printing row end
for(int col=col_start;col<=col_end;col++){
cout<<arr[row_end][col]<<" β€œ<<”,";
}
row_end–;
// for printing col end
for(int row=row_end;row>=row_start;row–){
cout<<arr[row][col_end]<<" β€œ<<”,";
}
col_end–;
// for printing row start
for(int col=col_end;col>=col_start;col–){
cout<<arr[row_start][col]<<" β€œ<<”,";
}
row_start++;

}
return 0;
}

Hello @vanshit02
It should be
Cin>>arr[I][j]

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.