Write the program for fibonacci in c++?

Answer Posted / joy

#include<iostream.h>
#include<conio.h>
voidmain()
{
clrscr();
int f1=0,f2=1,f3,n,i;
cout<<"Enter the number of terms...";
cin>>n;
cout<<"Fibonacci Series\n";
cout<<f1<<'\n'<<f2<<'\n';
for(i=3;i<=n;i++)
{
f3=f1+f2;
cout<<f3<<'\n';
f1=f2;
f2=f3;
}
getch();
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is COPY CONSTRUCTOR and what is it used for?

617


Difference between an inspector and a mutator

764


What is else if syntax?

673


When can I use a forward declaration?

622


What's the hardest coding language?

570






What is c++ hiding?

616


Explain polymorphism?

581


What is endianness?

615


What is static function? Explain with an example

557


What is const pointer and const reference?

590


What is void pointer in c++ with example?

593


Tell me can a pure virtual function have an implementation?

555


Write about the use of the virtual destructor?

604


What is a memory leak c++?

587


What is endl c++?

602