ITGUY21 - Editorial

Problem: https://www.codechef.com/PBK22020/problems/ITGUY21

DIFFICULTY:

EASY.

PROBLEM:

The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.

Program:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

    int t;
cin>>t;
    while(t--){
        int k;
cin>>k;
        long long arr[k];
        arr[0]=0;
        arr[1]=1;
        for(int i=2; i<k;i++){
            arr[i]=arr[i-1]+arr[i-2];
        }
        int j=1;
        while(j<=k){
            for(int i=0; i<j; i++){
                cout<<arr[i];
            }
            j++;
            cout<<endl;
        }
    }

}

#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
if(t>=1 && t<=50)
{
while(t–)
{
int n;
cin>>n;
if(n>=1&&n<=50)
{
int a=0,b=1;
int c,a1,b1;
//c=a+b;
for(int i=1;i<=n;i++)
{
a1=a;
b1=b;

            for(int j=1;j<=i;j++)
            {
               if(j==1)
               cout<<"0";
               else if (j==2)
               cout<<"1";
               else
               {
                     c=a1+b1;
               cout<<c;
               a1=b1;
               b1=c;
             
               }
            }
            cout<<endl;
        }
        }
        
       
    }
}
return 0;

}

can you please tell me why my answer is wrong?
it is correct for sample case like 5,7 but not submitting