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 / gobinath

#include<iostream>
using namespace std;
class A
{
public:
void print()
{
int a=0,b=1,c=0,n;
cout<<"Enter the number of : "<<endl;
cin>>n;
cout<<a<<" "<<b<<" ";
for(int i=1;i<=n-2;i++)
{
c=a+b;
a=b;
b=c;
cout<<c<<" ";
}
}
};
int main()
{
A a;
a.print();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by overhead in c++?

1044


What is a set in c++?

923


Why can’t you call invariants() as the first line of your constructor?

975


Can a program run without main function?

1100


What is the difference between a "copy constructor" and an "assignment operator" in C++?

1028


Define the process of error-handling in case of constructor failure?

969


What are the two types of polymorphism?

1069


What is a container class? What are the types of container classes in c++?

1175


Are there interfaces in c++?

948


What is encapsulation in c++ with example?

963


Differentiate between a copy constructor and an overloaded assignment operator.

1027


What is token c++?

989


Is c++ platform dependent?

1040


What is setf in c++?

1052


How many ways can a variable be initialized into in C++?

977