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
How a macro differs from a template?
Define the process of error-handling in case of constructor failure?
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.
What is & in c++ function?
why is iostream::eof inside a loop condition considered wrong?
What are namespaces in c++?
What is the real purpose of class – to export data?
Name the debugging methods that are used to solve problems?
Out of fgets() and gets() which function is safe to use and why?
What is a c++ class?
What is c++ library?
What is flag in computer?
How const int *ourpointer differs from int const *ourpointer?
List different attributes in C++?