0

How to do fibonacci series

6th Nov 2017, 2:46 PM
# Best Videos# 100% true video
7 Answers
+ 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; }
6th Nov 2017, 2:56 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 5
simpler language...? ummmm can't be faster instead? :P btw what did he answer you for this question?
6th Nov 2017, 3:33 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 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
6th Nov 2017, 2:53 PM
Harsh
Harsh - avatar
+ 1
i dont now you give me answers
6th Nov 2017, 2:47 PM
# Best Videos# 100% true video
+ 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
6th Nov 2017, 3:27 PM
# Best Videos# 100% true video
+ 1
print fibonacci series in function
11th Nov 2017, 2:33 PM
# Best Videos# 100% true video
+ 1
with conio and getch also
11th Nov 2017, 2:33 PM
# Best Videos# 100% true video