When i am testing this, its working perfectly but while submitting one of the test case is failing (output one)

#include
using namespace std;
int main()
{
int n;
int m=0;
cin>>n;
label:
if(n>=100 || n<=0)
{
cout<<“invalid value entered”<<endl;
cout<<“enter the value again”;
cin>>n;
cout<<endl;
if (n<100 || n>0)
{m=1;}
else
{
goto label;
}
}
else
{
m=1;
}

if (m==1)

{ int a=0;
int b=1;
int c=a+b;
int i=2;
while(i<=n)
{ if(i==2)
{
cout<<“0”<<endl;
cout<<"1 “<<c;
a=b;
b=c;
c=a+b;
}
else
{
for(int j=1;j<=i;j++)
{
cout<<c<<” ";
a=b;
b=c;
c=a+b;
}
}
cout<<endl;
i++;
}

}

return 0;

}

This is the code that i wrote. plz help

HI @kalwani.aryan, make 2 small changes:

  1. change data type to long long int for a, b, c ;
  2. check your code for testcase 1.

You’ll be able to figure out yourself now.
Hope this helps :slight_smile:

You are required to perform two changes in your program:

  1. It is written in the question, that each character is separated by a tab(use “\t”). But, you are using " " (single character space. ).

  2. As he said, use “long long int” datatype for all three variables a, b, c as they can take a bigger value than int.

If you get TLE as your error, then try to make your code effective.

Hope it would help.
If you still face any problem, feel free to ask.

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.