Column Wise Print

The Question is :
Print Column wise : – https://online.codingblocks.com/player/12975/content/4825?s=2165

My Logic is that in a column, the 2nd index doesn’t change and only the first one does. (ie 00,10,20,30,40, etc.)
Based on this logic I have written this code, please tell me where I am wrong :

#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[j][i]<<", ";
        }
        
        else
        {

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

}

cout<<“END”;
return 0;
}
Please Let me know where I am wrong

please share question link of hacker blocks, i can not open this, or share screenshot of question.

Hey Srindhi, you are making a small mistake, for accessing a 2D array element we use arr[row_no][col_no]. So, update your printing statements like this cout<<arr[i][j]<<", "; because now you are using cout<<arr[j][i]<<", "; which is resulting in wrong answer.

Here is a suggestion when you are posting your doubts from next time please mention the problem’s exact name and copy your whole code on ide, save it and share that link here.