Site Loader
Get a Quote

 fibonacci series program in c++

 fibonacci series program in c++: –Hi Readers, in this blog we will create a C++ program to generate or display fibonacci series in c++.First of all, we need to know what is the meaning of fibonacci series program and their logic to generate fibonacci series

 

 fibonacci series logic in c++

Fibonacci sequence are few numbers of series are 0, 1, 1, 2, 3, 5, 8 etc, Except first two terms in sequence every other term is the sum of two previous terms.

C++ program to generate Fibonacci series program

Here we have written a program in c++ to generate fibonacci series.we have used header file on the top of the program then used the namespace after that we have taken input from the console to display

fibonacci series

#include<iostream>

#include<conio.h>

using namespace std;

main()

{

   int n, c, first = 0, second = 1, next;

   cout << "Enter the number of terms of Fibonacci series you want" << endl;

   cin >> n;

   cout << "First " << n << " terms of Fibonacci series are :- " << endl;

   for ( c = 0 ; c < n ; c++ )

   {

      if ( c <= 1 )

         next = c;

      else

      {

         next = first + second;

         first = second;

         second = next;

      }

      cout << next << endl;

   }

 getch();

   return 0;

}




fibonacci series program

I hope you would like this topic.Thanks

Post Author: TechieFlair

Leave a Reply

Your email address will not be published.