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 private, public and protected inheritance?
What does override mean in c++?
Why is c++ called oops?
How delete [] is different from delete?
Explain linked list using c++ with an example?
What is insertion sorting?
What is an incomplete type in c++?
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list
If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
Can I create my own functions in c++?
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
What is c++ w3school?
Why do we use setw in c++?
Explain differences between alloc() and free()?
What is the use of data hiding?