Write the program for fibonacci in c++?

Answer Posted / ria

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr ();
int n,f1,f2,f3,i;
cout<<"/n input the no.of terms";
cin>>n;
f1=-1;
f2=1;
cout<<"/n the fibonacci series is ";
for(i=1,i<=n,i++)
{
f3=f1+f2;
cout<<"/n"<<f3;
f1=f2;
f2=f3;
}
getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are default parameters? How are they evaluated in c++ function?

887


find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.

2214


what is data abstraction in C++?

834


What is function overloading in C++?

1077


What is the most useful programming language?

809


What is malloc in c++?

732


What does return 0 do in c++?

804


Are there interfaces in c++?

742


What is the use of setprecision in c++?

724


What is private inheritance?

834


What is input operator in c++?

776


What is the difference between the functions rand(), random(), srand() and randomize()?

947


What are static member functions?

805


How long it will take to learn c++?

795


How is c++ different from java?

773