1.

Write a cpp program to display fibonacci series

Answer»

Answer:

#include

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;

  }

  return 0;

}



Discussion

No Comment Found