Column wise wave print

this is not passing all test cases

#include
using namespace std;

void wavePrint(int input[][1000], int m, int n)

{

int j = 0, i;

while(j<n)
{
for(i = 0; i<m; i++)

{
  cout<<input[i][j]<<" ";
}
j++;
if(j<n)
{
  for(i = m - 1; i>=0; i--)
  {
    cout<<input[i][j]<<" ";
  }
}
j++;

}
}

@AKSHET
you need to print END as well
check sample output
image

Thanks for responding fast

But I have used END at the end

In this code it somehow missed

@AKSHET
pls save ur code here https://ide.codingblocks.com/ and then share the generated link

#include
using namespace std;

int main()
{
int n,m;
cin>>n>>m;
int a[10][10];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
int strow=0;
int endrow=n-1;
int stcol=0;
int endcol=m-1;
while(strow<=endrow and stcol<=endcol)
{
for(int i=strow;i<=endrow;i++)
{
cout<<a[i][stcol]<<", β€œ;
}
stcol++;
for(int i=endrow;i>=strow;i–)
{
cout<<a[i][stcol]<<”, ";
}
stcol++;
}
cout<<β€œEND”;
return 0;
}

@AKSHET
hello akshet,
ur code is almost correct

execute ur second loop only when this condition if(stcol<=endcol) satisfies

@AKSHET
check ur updated code here -> https://ide.codingblocks.com/s/192276

Thanks, for you response I solve my problem

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.