ARRAY wave print challenge

#include<bits/stdc++.h>
using namespace std;
int main() {
int n,m,f=0;
int arr[10][10];
cin>>n>>m;
if(m%2==0)
{
f==1;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>arr[i][j];
}
}

	for(int i=0;i<m;i++)
	{
		if(i%2==0)
		{
			for(int r=0;r<n;r++)

			{   if((i==m-1)&&(f==0)&&(r==n-1))

			    {cout<<arr[r][i]<<", END";
				 return 0;
                }
				cout<<arr[r][i]<<',';
			}
		}
		else
		{
			for(int r=n-1;r>=0;r--)

			{   if((i==m-1)&&(f==1)&&(r==0))

			    {cout<<arr[r][i];
				cout<<", END";
				return 0;
                }
				cout<<arr[r][i]<<',';
				
			}
		}


		
	}

return 0;

}

this is my code.
first I am dividing m by 2, to decide where i have to print END
then have two loops, from up to down and vice-versa
in loop, i am checking, if this is the last column, last row and f==1(when number of column is even), if it is so, i orint end and return,
this works for odd number of columns, but not for even number. why so?

hello @shashank3256,
why u are f when u are already using i==m-1 and r==0 or r==n-1 condition.

remove f condtion it will work.

yeah, i got that, but the thing is, even with f, it should had worked. Thats my doubt.

paste ur code here -> https://ide.codingblocks.com/
and share the link. your code should work

sorry but don’t know why, but am not getting shareable link for the code there

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.