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
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
What is the hardest coding language to learn?
What is the difference between #import and #include?
How can we access protected and private members of a class?
Can I make ios apps with c++?
How new/delete differs from malloc()/free?
Is c++ a good beginners programming language?
What is difference between rand () and srand ()?
Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?
What is a node class in c++?
What is purpose of abstract class?
Why do we use using namespace std in c++?
What is the equivalent of Pascal's Real a) unsigned int b) float c) char
Explain the auto storage classes in c++.
Define the process of handling in case of destructor failure?