Advertisement
galib71

Fibonacci series COA t-2

Sep 25th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4. int main()
  5. {
  6. int x,a=0,b=1,frwrd;
  7.  
  8. cout<<"Enter the number of terms"<<endl;
  9. cin>>x;
  10. cout<<"Fibonacci series are : ";
  11.  
  12. for (int c=0;c<x;c++)
  13. {
  14. if (c<=1)
  15. frwrd=c;
  16. else
  17. {
  18. frwrd=a+b;
  19. a=b;
  20. b=frwrd;
  21. }
  22. cout<<frwrd<<" ";
  23. }
  24. cout<<endl;
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement