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 are destructors?

952


What is the copy-and-swap idiom?

1065


What is the difference between C and CPP?

1121


What causes a runtime error c++?

1086


How do I exit turbo c++?

1022


What is the fastest c++ compiler?

1048


What is ifstream c++?

990


What is a volatile variable in c++?

1387


Comment on local and global scope of a variable.

1098


Can I learn c++ as my first language?

1072


What is an inclusion guard?

1128


How is new() different from malloc()?

1079


Which bit wise operator is suitable for putting on a particular bit in a number?

1158


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

1129


Explain what is polymorphism in c++?

1096