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 a base class?
How many ways can a variable be initialized into in C++?
Is swift a good first language?
When you overload member functions, in what ways must they differ?
What is the standard template library (stl)?
You want to link a c++ program to c functions. How would you do it?
What does std mean in c++?
When is the destructor called?
What is purpose of new operator?
How are virtual functions implemented in c++?
How can I learn c++ easily?
What are literals in C++?
What are the benefits of operator overloading?
What is a friend function in c++?
What data encapsulation is in c++?