C++, Programmimg Languages

Write a program in C++ to print Fibonacci series

#include<iostream.h>

#include<conio.h>

class fib

{

private:

f0, f1,fb;

public:

fib();

void increment ();

void display();

};

fib::fib()

{

f0=0;

f1=1;

fb=f0+f1;

}

fib::increment()

{

f0=f1;

f1=fb;

fb=f0+f1;

}

fib::display()

{

cout<<“Fibonacci series=”<<f0<<‘\t'<<f1<<‘\t'<<fv;

}

void main()

{

clrscr();

fib F;

F.increment();

F.display ();

getch();

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s