Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write the program for fibonacci in c++?

Answer Posted / smita

#include<iostream.h>
#include<conio.h>
class fibonacci
{
int f0,f1,f2;
public:
fibonacci()//constructor
{
f0=0;
f1=1;
f2=f0+f1;
}

void cal()
{
f0=f1;
f1=f2;
f2=f0+f1;
}
void dis()
{
cout<<"fibonacci:"<<f2<<endl;
}

};
void main()
{
fibonacci obj;
int n;
cout<<"How many no. displayed:"<<endl;
cin>>n;
for(int i=0;i<=n-1;i++)
{

obj.dis();
obj.cal();
}

getch();
}

Is This Answer Correct ?    57 Yes 34 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does iomanip mean in c++?

1214


When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

1116


Explain the scope of resolution operator.

1127


What happens when you make call 'delete this;'?

1112


What is protected inheritance?

1058


What is time h in c++?

1150


What is a dangling pointer in c++?

1169


Why is polymorphism useful?

1082


What programming language should I learn first?

1114


What is a tree in c++?

983


What is late binding c++?

1002


What is the difference between mutex and binary semaphore?

1254


What is singleton pattern in c++?

1008


What is the maximum combined length of command line arguments including the space between adjacent arguments?

1012


Which one between if-else and switch is more efficient?

1090