Fibonacci Series program in C++

Fibonacci Series program in C++

How to Write Fibonacci Series program? Fibonacci Series, or Fibonacci Numbers are the numbers displayed in the following sequence. Fibonacci Series = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 …

C++ Fibonacci program :



#include <iostream>
using namespace std;

int main() 
{
    int Number, Next, i = 0, First_Value = 0, Second_Value = 1;
    
    cout << "Please Enter the Range Number : ";
    cin >> Number;
    cout << "Fibbonaci Series : ";
    
    while(i < Number)
    {
        if(i <= 1)
            Next = i;
        else
        {
            Next = First_Value + Second_Value;
            First_Value = Second_Value;
            Second_Value = Next;
        }
        cout << Next << " ";
        i++;
    }   
    
    return 0;
}


Output :