Search & Find out

Sunday, December 6, 2009

FIBONACCI SERIES



#include "iostream.h"
#include "conio.h"
class fib
{
    private:
        int n,a,b,x;
    public:
        fib ()
        {
            a = 0;
            b = 1;
        }
        void accept ()
        {       cout << "Welcome to Fibonacci Series\n\n";
            cout << "Enter the number of elements: ";
            cin  >> n;
        }
        void cal ();
};
void fib :: cal ()
{
    cout << "\n\n\nFibonacci Series:  0  1";
    for (int i=0; i
    {
        x = a + b;
        cout << "  " << x;
        a = b;
        b = x;
    }
}
void main ()
{
    clrscr ();
    fib F;
    F.accept ();
    F.cal ();
getch ();
}



Get the executable ( .exe ) file for this program..
Download

0 comments:

Post a Comment

 

My Blog List

Term of Use