Arrays-wave print row wie

#include
using namespace std;

int main(){
int M,N;
cin>>M>>N;
int arr[M][N];

for (int i = 0; i < M; i++)
{
    for (int j = 0; j < N; j++)
    {
       cin>>arr[i][j];
    }
    
}

cout<<endl;

for (int i = 0; i < M; i++)
{
    if (i%2==0)
    {
        for (int j = 0; i < N; j++)
        {
            cout<<arr[i][j]<<" ";
        }
        
    }

    else
    {
        for (int j = N-1; j >=0 ; j--)
        {
            cout<<arr[i][j]<<" ";
        }
     
    }
    
    
}

return 0;
}

my code is shoeing correct output but after completing it’s task it is giving garbage value
please tell what’s wrong

@sahilkumar23102003_bbf6ee38349d98a1, u wrote i<M instead of j<M,
and to submit the code on hackerblocks here’s the code u were missing “,” and “END”

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.