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 disadvantages of pointers?

987


What is the best book for c++ beginners?

982


What are friend functions in C++?

1011


Explain the concept of friend function in c++?

1052


How do I download c++?

965


Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.

1065


Describe public access specifiers?

1040


what is COPY CONSTRUCTOR and what is it used for?

1024


What is an iterator class in c++?

1093


What is the difference between global variables and static varables?

1072


Is c++ built on c?

972


What are pointer-to-members in C++? Give their syntax.

1084


What is the use of lambda in c++?

970


Can you pass a vector to a function?

912


Explain the purpose of the keyword volatile.

1105