ARRAYS-WAVE PRINT ROW WISE(edited)

why i am getting run error in the 4th case?

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

}

Hey Aryan, can you please your code on ide, save it and share that link as the code you have copied here is having a lot of compilation errors.

#include <bits/stdc++.h>
using namespace std;

void wave_print(int arr[1000][1000],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[1000][1000];
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”;
}

Try submitting this code.

Do add the problem link along with a link to your code from next time.