Fibonacci Pattern 4

Why some test cases are failing for this code.

#include
using namespace std;

int main()
{
int n,x=1,y=1,z=x+y,a=0;
cin>>n;

for(int i=1;i<=2;i++)
{
for(int j=1;j<=i;j++)
{
cout<<a<<"\t";
}

    a++;
    cout<<endl;

}

for(int i=3;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
cout<<z<<"\t";
x=y;
y=z;
z=x+y;
}

  cout<<endl;

}

return 0;
}

Hello @mvganeshk15

  1. From the next time share your code using Online Coding Blocks IDE.
    The way you have sent it, is introducing many syntax errors to it.
    Steps:
    1.1. Paste your code on IDE.
    1.2. Save it there.
    1.3. Share the URL generated.

  2. Now coming back to your code:
    You have missed one boundary case:
    when n=1?
    Expected Output:
    0
    Your Output:
    0
    1 1

Hope, this would help.
Give a like, if you are satisfied.

1 Like

Sorry for that. I am not able to copy the url from the ide. Please guide me how to copy it.

Sure @mvganeshk15,

STEPS:

  1. Paste your code on https://ide.codingblocks.com/

  2. Save it there.

  3. Share the URL generated.

Just copy that and paste it here.:blush:

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.