Not all test cases working

#include
using namespace std;
int main () {

int n,i,j;
cin>>n;
for(i=1;i<=n;i++)
{
  if(i%2!=0)
  {for(j=1;j<=i;j++)
  {cout<<"1";}
  }

  else
  {
        for(j=1;j<=i;j++)
        {
            if(j==1||j==i)
            {cout<<"1";}
            else
            cout<<"0";
        }

  } cout<<endl;

}


return 0;

}

@lakshit For Manmohan Loves Pattern II
You have posted your doubt under Manmohan Loves Pattern II. I don’t think your code relates to it.
Anyway, Check your logic once:
Considering the sample input:
Sample Input
5
Sample Output
1
11
202
3003
40004

You can observe that 0th row will have 1. After that from the 1st row, the first and the last element of each row will be the row number. There will be zeros in between.

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.