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
What is enum class in c++?
Keyword mean in declaration?
Comment on local and global scope of a variable.
How new/delete differs from malloc()/free?
Is c++ a good beginners programming language?
What are the advantages of c++?
If all is successful, what should main return a) 0 b) 1 c) void
What does it mean to declare a member function as virtual?
What are arrays c++?
Out of fgets() and gets() which function is safe to use and why?
We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?
What are inline functions? What is the syntax for defining an inline function?
what is the difference between linear list linked representaion and linked representation? what is the purpose of representing the linear list in linked represention ? is it not avoiding rules of linear represention?
What is the protected keyword used for?
Do class declarations end with a semicolon? Do class method definitions?