0
How to do fibonacci series
7 Respuestas
+ 5
#include <iostream>
using namespace std;
int main(){
int a=0,b=1,fibLength=20;
while(fibLength--){
cout<<a<<endl;
a+=b;//plus
a^=b;//swap
b^=a;
a^=b;
}
return 0;
}
+ 5
simpler language...?
ummmm can't be faster instead? :P
btw what did he answer you for this question?
+ 2
This might help you:-
#include <iostream>
using namespace std;
int main()
{
int n, t1 = 0, t2 = 1, nextTerm = 0;
cout << "Enter the number of terms: ";
cin >> n;
cout << "Fibonacci Series: ";
for (int i = 1; i <= n; ++i)
{
// Prints the first two terms.
if(i == 1)
{
cout << " " << t1;
continue;
}
if(i == 2)
{
cout << t2 << " ";
continue;
}
nextTerm = t1 + t2; t1 = t2; t2 = nextTerm;
cout << nextTerm << " ";
}
return 0;
}
//Credits to programiz.com
+ 1
i dont now you give me answers
+ 1
i want more answer in more simlper language because our teacher dont teach us properly and they dont know c++ properly but they show they are a very good teacher of computer
+ 1
print fibonacci series in function
+ 1
with conio and getch also