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

Simplest one:

#include <iostream>

using namespace std;

int main()
{
int x, a = 0, b = 1, i, z;
cout << "Lets Start!" << endl;
cout << "No. of elements in the series = ";
cin >> x;
cout << "Series: " << endl;
for(i = 0; i < x; i++){
z = a + b;
a = b;
b = z;
cout << z << endl;
}

return 0;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is abstract class in c++?

998


What is abstraction with real time example?

1111


What is a pointer how and when is it used?

1044


What do you mean by “this” pointer?

1041


Define stacks. Provide an example where they are useful.

955


What is the full form nasa?

1041


What is a catch statement?

995


Should you pass exceptions by value or by reference?

1094


What are the uses of c++ in the real world?

990


How can you link a c program with a c function?

1020


What is the difference between c++ and turbo c++?

1116


What is protected inheritance?

1012


Is map thread safe c++?

1031


How can you say that a template is better than a base class?

1034


Using a smart pointer can we iterate through a container?

1033