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

Is nan a c++?

1160


Is c++ a software?

1206


What is purpose of new operator?

1073


Out of fgets() and gets() which function is safe to use?

1136


Is there structure in c++?

1033


Why is main an int?

997


Is it possible to get the source code back from binary file?

1374


What is the prototype of printf function?

1192


Can I learn c++ without knowing c?

1069


What is pure virtual function?

1073


Why do we need c++?

1064


What is the best ide for c++?

1096


Is c or c++ more useful?

1056


write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;

2009


Can I learn c++ without learning c?

1020