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

What is enum class in c++?

933


Keyword mean in declaration?

797


Comment on local and global scope of a variable.

872


How new/delete differs from malloc()/free?

856


Is c++ a good beginners programming language?

786


What are the advantages of c++?

1289


If all is successful, what should main return a) 0 b) 1 c) void

780


What does it mean to declare a member function as virtual?

791


What are arrays c++?

822


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

931


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?

820


What are inline functions? What is the syntax for defining an inline function?

812


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?

1982


What is the protected keyword used for?

845


Do class declarations end with a semicolon? Do class method definitions?

859