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
What is abstract class in c++?
What is abstraction with real time example?
What is a pointer how and when is it used?
What do you mean by “this” pointer?
Define stacks. Provide an example where they are useful.
What is the full form nasa?
What is a catch statement?
Should you pass exceptions by value or by reference?
What are the uses of c++ in the real world?
How can you link a c program with a c function?
What is the difference between c++ and turbo c++?
What is protected inheritance?
Is map thread safe c++?
How can you say that a template is better than a base class?
Using a smart pointer can we iterate through a container?