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 operator is used to access a struct through a pointer a) >> b) -> c) *
What is the difference between #import and #include?
What does scope resolution operator do?
Can constructor be private in c++?
How can you quickly find the number of elements stored in a static array?
Please explain the reference variable in c++?
What is the c++ programming language used for?
What is an html tag?
What is a sequence in c++?
Is c++ a float?
What are the two shift operators and what are their functions?
What is main function in c++ with example?
What is bubble sort c++?
Write a code/algo to find the frequency of each element in an array?
What is the use of object in c++?