Advertisement
Programmin-in-Python

C++ Program to print Fibonacci Series

Jan 12th, 2022
1,015
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n, f=0, s=1, t;
  6.  
  7.     cout << "Enter the Number of Terms : ";
  8.     cin >> n;
  9.  
  10.     cout << f << endl;
  11.     cout << s << endl;
  12.  
  13.     for(int i=2; i<n; i++){
  14.         t = f + s;
  15.         cout << t << endl;
  16.  
  17.         f = s;
  18.         s = t;
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement