Write the program for fibonacci in c++?
Answer Posted / gobinath
#include<iostream>
using namespace std;
class A
{
public:
void print()
{
int a=0,b=1,c=0,n;
cout<<"Enter the number of : "<<endl;
cin>>n;
cout<<a<<" "<<b<<" ";
for(int i=1;i<=n-2;i++)
{
c=a+b;
a=b;
b=c;
cout<<c<<" ";
}
}
};
int main()
{
A a;
a.print();
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Is nan a c++?
Is c++ a software?
What is purpose of new operator?
Out of fgets() and gets() which function is safe to use?
Is there structure in c++?
Why is main an int?
Is it possible to get the source code back from binary file?
What is the prototype of printf function?
Can I learn c++ without knowing c?
What is pure virtual function?
Why do we need c++?
What is the best ide for c++?
Is c or c++ more useful?
write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;
Can I learn c++ without learning c?