how to print a fibonacci series.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to print a fibonacci series..

give me a program

20th Sep 2016, 3:21 AM
Akshay Kumar
Akshay Kumar - avatar
1 Answer
+ 2
#include <iostream> using namespace std; int main() { long a,b,c,i,n; a=0; b=1; cout<<"enter number of terms you want to print"<<endl; cin>>n; cout<<a<<" "<<b; for(i=1;i<=n-2;i++) { c=a+b; cout<<" "<<c; a=b; b=c; } return 0; } hope you got the answer;)
20th Sep 2016, 3:47 AM
Descifrador
Descifrador - avatar