Fibonacci Pattern

#include
using namespace std;
int main() {
int n;
cin>>n;
int i,j,f1,f2,f3,f;
f1=0;
f2=1;
f3=1;
cout<<f1<<endl;
cout<<f2<<" β€œ<<f3<<endl;
for(i=2;i<n;i++){
for(j=0;j<=i;j++){
f=f2+f3;
cout<<f<<” ";
f2=f3;
f3=f;
}
cout<<endl;
}
return 0;
}

This code pass only two test cases not all test cases.

you are printing atleast 2 rows. what if n=1? check this case also.
if n==1 dont print second row…
thanks

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.