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