C++ Program to find Fibonacci Series

ad+1



Program:

// Program By http://solutionscpp.blogspot.com
// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com

#include <iostream>
using namespace std;

int main()
{
    int n=0 , first = 1, second = 1, next=0 ;

    cout << "Enter total number of terms: ";
    cin >> n;

    cout << "Fibonacci Series is: " << first << " " << second << " ";

    for (int i = 1; i <= n-2; ++i)
   {
        next = first+ second;
        cout << next << " ";
        first = second;
        second = next;
   }

    return 0;
}

Output:

2 comments: Leave Your Comments