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 a map in c++?

591


describe private access specifiers?

656


How would you call C functions from C++ and vice versa?

650


What is the difference between function overloading and operator overloading?

583


What is the most useful programming language?

618






When should I use unitbuf flag?

598


What are function prototypes?

658


Evaulate: 22%5 a) 2 b) 4 c) 0

679


What are shallow and deep copy?

608


Ask to write virtual base class code?

2163


Difference between delete and free.

625


Show the application of a dynamic array with the help of an example.

599


When does the c++ compiler create temporary variables?

584


Why was c++ created?

569


How would you use qsort() function to sort an array of structures?

732