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 is difference between n and endl in c++?

1028


What are the advantages of using pointers in a program?

1092


What is c++ mutable?

1079


Describe the setting up of my member functions to avoid overriding by the derived class?

1069


What is the arrow operator in c++?

948


What is function prototyping?

1039


What is the meaning of c++?

965


We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?

1034


What is the difference between public and private data members?

1116


Why should we use null or zero in a program?

972


If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?

1066


Why would you use pointers in c++?

1090


Define pointers?

1003


What does floor mean in c++?

1016


List down the guideline that should be followed while using friend function.

1005