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

State the difference between delete and delete[].

1102


Define whitespace in C++.

1204


What is constructor c++?

1114


What are the advantages of early binding?

1067


What do you mean by friend class & friend function in c++?

1056


Which is better turbo c++ or dev c++?

1071


Explain what are the sizes and ranges of the basic c++ data types?

1157


What is microsoft c++ redistributable 2013?

1099


Why do we use double in c++?

1054


What are register variables?

1143


What is a vector c++?

1171


What is #include cstdlib in c++?

1178


What is the need of a destructor? Explain with the help of an example.

1025


Is c++ the hardest programming language?

1127


Comment on assignment operator in c++.

1109