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

How a macro differs from a template?

861


Define the process of error-handling in case of constructor failure?

773


What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

831


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

810


What is & in c++ function?

786


why is iostream::eof inside a loop condition considered wrong?

812


What are namespaces in c++?

799


What is the real purpose of class – to export data?

838


Name the debugging methods that are used to solve problems?

763


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

926


What is a c++ class?

846


What is c++ library?

791


What is flag in computer?

799


How const int *ourpointer differs from int const *ourpointer?

810


List different attributes in C++?

816