Not able to pass test case

In wave print question of araay
Here is my code:

#include
using namespace std;
int main() {
int m,n;
cin>>m>>n;
if(m>10||n>10)
{
return 0;
}
int arr[10][10];
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
cin >> arr[i][j];
}
}

for (int i = 1; i <= m; i++)
{
	if ((i % 2) == 1)
	{
		

	for(int j=1;j<=n;j++)
		{

			cout << arr[j][i] << ","<<" ";
	
		}
	}
	else if((i%2)==0)
	{

		for (int j = n; j >= 1; j--)
		{

			cout << arr[j][i] << ","<<" ";

		}
	}
	
}
cout << "END";
return 0;

}

@1706157
hello satyam,
declare array as int arr[11][11];

still not able to pass the testcase.

@1706157
ok then pls save ur code on https://ide.codingblocks.com/ and share the link

here is the link.

@1706157

a) declare ur array as arr[m+1][n+1]
b) in line no 15, it should be n
c) in line no 21 and 31 ,it should be m

Now , its working fine but I dont understand why are we taking an extra space and using arr[m+1][n+1] instead of arr[m][n]
Thanks for the help.

@1706157
in ur code u r accessing (m,n) index which mean m+1 th row and n+1 column right ?
because indexing starts from zero. so u need to declare an array of size m+1 * n+1

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.