My code is correct but not giving exact output

question:
wave print column wise(coding blocks question)

answer:
#include
using namespace std;
int main() {
int m;
int n;
int row,col;
cin>>m>>n;
int arr[m][n];
for(row=0;row<=m-1;row++)
{
for(col=0;col<=n-1;col++)
{
cin>>arr[row][col];
}
}
for(col=0;col<=n-1;col++)
{
if(row%2==0)
{
for(row=0;row<=m-1;row++)
{
cout<<arr[row][col]<<",";
}

}
else 
{
	for(row=m-1;row>=0;row--)
	{
		cout<<arr[row][col]<<",";
	}
}

}
cout<<“END”;
return 0;
}

hello @aarijrab i have corrected your code ,there were some small errrors and i have corrected them .
the link for the correct code is https://ide.codingblocks.com/s/323945.
i hope i have cleared your doubt .
Happy Learning!!

bhaiya could you mark in comments in program where i have done a mistake…i am not able to find!..

@aarijrab https://ide.codingblocks.com/s/324031 this is the correct code link .
and https://ide.codingblocks.com/s/323945 this link have your code and i have commented your mistakes. please go through this .
i hope i have cleared your doubt .
Happy Learning !!

bhaiya i understood your answer…but i have a doubt…how does input produce different results…line cin>>arr[row][col] and cin>>arr[col][row]…please explain

@aarijrab lets suppose your row is 3 and col is 2 that means 3rd row and 2nd column of the matrix .
and in this if you will take input as cin>>arr[row][col].then it will be stored in the third row and second column .whereas in contrary to this if you do cin>>arr[col][row] then your element will be stored in the 2nd row and thirs column.
this creates a difference as your making a difference while the storing elements only.
ConvertLinearIndicesToSubscriptsForMatricesExample_01

the picture here shows the indexing and you can clearly see the difference how it will create a difference in input.
i hope i have cleared your doubt .
Happy Learning !!

@aarijrab if your doubt is cleared mark it as resolved