+ 4
Using for loops write program to generate fibonacci sequence 1 1 2 3 5 8 1 3 2 1
https://www.sololearn.com/discuss/1035622/?ref=app https://www.sololearn.com/discuss/1038399/?ref=app
5 Antworten
+ 19
I made a pseudo code for your question.
Begin
f=o
s=1
IF f <1 THEN
print 1
ELSE
WHILE f<8 then
ans=f+s
f=s
f=ans
print ans
END WHILE
END IF
END.
+ 1
#include <iostream>
using namespace std ;
int main()
{
long n,i,a=0,b=1,c;
cout<<" enter range"<<endl;
cin>>n;
cout<<a<<" "<<b<<" ";
for(i=1;i<=n;i++)
{
c=a+b;
cout<<c<<" ";
a=b;
b=c;
return 0;
}
0
https://code.sololearn.com/c2g1JX4oZQCb/?ref=app