This article show the program to display Fibonacci series in C/C++.
C code to Display Fibonacci Series
#include #include #include int main(){ clrscr(); long f0=0,f1=1,f2,i,n; cout<<"\" This program will display Fibonacci Series of n numbers.\""<<endl<<endl; xx: cout<<"How many numbers ?. Give a integer number."<<endl; cin>>n; if(n<0) { cout<<"Negative number is not allow, Please give a integer number."<<endl; goto xx; } if(n>46) { cout<<"Greather than 46 is not allow"<<endl; goto xx; } cout<<endl; cout<<"Fibonacci Series of 1 to "<<n<<" is:"<<endl; cout<<f1<<endl; for(i=1;i<n;i++) { f2=f0+f1; cout<<f2<<endl; f0=f1; f1=f2; } getch(); }