Only one test case pass case number 4

#include
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];

	}
}

int sr=0,sc=0,er=r-1,ec=c-1;
while(sr<=er && sc<=ec){
	for(int i=0;i<=ec;i++){
		cout<<a[sr][i]<<","<<" ";
	}
	sr++;
	for(int i=sr;i<=er;i++){
		cout<<a[i][ec]<<","<<" ";
	}
	ec--;

	for(int i=ec;i>=sc;i--){
		cout<<a[er][i]<<","<<" ";

	}
	er--;
	for(int i=er;i>=sr;i--){
		cout<<a[i][sc]<<","<<" ";

	}
	sc++;


}
cout<<"END";

return 0;

}

Hello @yashtripathi6969_0cd127807d833066,
Could you pls share the question link of hacckerblocks. Because I need to look the whole question.

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.