Fibonacci Series


  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int a=0,b=1,c=0,n;
  7. cout<<"Enter the number of terms you wanna see: ";
  8. cin>>n;
  9. cout<<a<<" "<<b<<" ";
  10. for(int i=1;i<=n-2;i++)
  11. {
  12. c=a+b;
  13. a=b;
  14. b=c;
  15. cout<<c<<" ";
  16. }//Coding by: Jerry Johns
  17. //http://jerryjo94.blogspot.com
  18. getch();
  19. }

0 comments:

Post a Comment