Wave Print Wrong Output

Wrong Output

#include
using namespace std;
int main() {
long long int M,N;
cin >> M >> N;
long long int arr[M][N];
for(long long int i=0;i<M;i++)
{
for(long long int j=0;j<N;j++)
{
cin >> arr[M][N];
}
}
for(long long j=0;j<N;j++)
{
if(j%2 == 1)
{
for(long long int i=M-1;i>=0;i–)
{
cout << arr[M][N]<<", “;
}
}
else
{
for(long long int i=0;i<M;i++)
{
cout << arr[M][N]<<”, ";
}
}
}
cout << “END”;
}

@rhythm9 other than creating the array, use arr[i][j] for entering the values or printing them instead of arr[m][n].
Hope this helps

1 Like

oh shit, I made some really careless mistake.

thanx for your help !!!