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


Please Help Members By Posting Answers For Below Questions

Does dev c++ support c++ 11?

565


what are Access specifiers in C++ class? What are the types?

634


Why are pointers used?

586


What is c++ vb?

618


what are the iterator and generic algorithms.

1466






Do you need a main function in c++?

561


Tell me can a pure virtual function have an implementation?

558


Why do we use classes in programming?

580


Difference between a homogeneous and a heterogeneous container

669


What are the implicit member functions of class?

601


Is c++ platform dependent?

639


What is the arrow operator in c++?

567


What is the difference between structure and class?

564


Out of fgets() and gets() which function is safe to use and why?

733


Why is main function important?

591