Tuesday, 20 November 2012

How to Generate a Fibonacci series in C++ Programming?


#include <iostream>
using namespace std;
int main()
{
int i, a=0,b=1,c, num;
cout << "Enter Number for how many times generate Series: ";
cin >>num;
cout << "Fibonaci Series is: \n";
for(i=0;i<num;i++)
{
c=a+b;
a=b;
   b=c;
cout << "\t" <<c<<endl;
}
return 0;
}

1 comment:

  1. C++ Program to Generate Fibonacci series

    Fibonacci Series is in the form of 0, 1, 1, 2, 3, 5, 8, 13, 21,...... To find this series we add two previous terms/digits and get next term/number.

    ReplyDelete