Wave print row wise

Question on Hacker Rank to print row wise.
Link to complete question: https://hack.codingblocks.com/practice/p/369/216

My Solution :

#include

using namespace std;

int main()
{
int arr[10][10];
int row=0;
int col=0;
cin>>row>>col;
for(int i=0;i<row;i++)
{
for(int j=0;j<col;j++)
{
cin>>arr[i][j];
}

}

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

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

}

cout<<“END”;
return 0;
}

Link to code : http://tpcg.io/9yxYL8
None of the test cases are passing, please can you help and tell me the mistake.

In the last for loop , it should be for(int j=col-1;j>=0;j–).

Hey, update your code’s line:33 as this for(int j=col-1; j>=0; j--). Otherwise your code will not handle the cases where no. of rows and no. of columns are different. For eg.
input:
4 5
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45

Hi,
Thank you, the issue was resolved.