sahajjain01

Display first n terms of fibonacci series.

Aug 21st, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. //Program to display first n terms of fibonacci series.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. void main()
  5. {
  6.     clrscr();
  7.     long a,b=0,c=1,d=1;
  8.     cout<<"Enter the number of terms of fibnoacci series to display: ";
  9.     cin>>a;
  10.     cout<<"The first "<<a<<" terms of fibonacci series are: "<<endl;
  11.     for(int i=0;i<=a;i++)
  12.     {
  13.         d=b+c;
  14.         b=c;
  15.         c=d;
  16.         cout<<d<<" ";
  17.     }
  18.     getch();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment