Arrays-wave print row wise

Why I’m getting run error in 4th test case

#include
#include
using namespace std;
void wave_print(int**arr,int m,int n)
{ int i=0,j=0;
while(i!=m)
{
if(j==0)
{
for(j=0;j<n;j++)
cout<<arr[i][j]<<", “;
i++;
}
else if(j==n)
{
for(j=n-1;j>=0;j–)
cout<<arr[i][j]<<”, ";
i++;
j=0;
}
}
}
int main()
{
int n,m;//m=rows,n=columns
cin>>m>>n;
int arr;
arr=(int
)malloc(msizeof(int));
for(int i=0;i<m;i++)
{
arr[i]=(int
)malloc(n*sizeof(int));
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>arr[i][j];
}
}
wave_print(arr,m,n);
cout<<“END”;

}

You are doing mistake in declaring the 2D array . As the input size is small , you can declare the arr globally of size 100x100 .
I have modified ur code here , you can go through it .