Write the program for fibonacci in c++?
Answer Posted / irushad abdulrahman
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a=-1, b=1, c, x;
cout << "Enter a number to find FIBONACCI less than
that:";
cin >>x;
do
{
c=a+b;
cout << c << "\t";
a=b;
b=c;
}
while (c<=(x-c));
cout <<"\n";
system ("pause");
return 0;
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
What do you mean by friend class & friend function in c++?
What is srand c++?
Specify some guidelines that should be followed while overloading operators?
Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?
Differentiate between late binding and early binding.
total amount of milk produced each morning and then calculates and outputs the number of cartons needed for this milk , the cost of producing the milk and the profit from producing this milk.
Explain the term memory alignment?
What is searching? Explain linear and binary search.
How do you print a string on the printer?
What is an html tag?
Why null pointer is used?
State the difference between pre and post increment/decrement operations.
What is c strings syntax?
What is an incomplete type in c++?