Write the program for fibonacci in c++?
Answer Posted / nitish kumar nirala
#include<iostream.h>
#include<conio.h>
int fibo(int);
void main()
{
int n,fibbon;
cin>>n;//input number to find fabbonic series
fibbo=fibo(n);
cout<<fibbo<<"
";
getch();
}
int fibo(n)
{
if(n==0)
{
return 0;
}
elseif(n==1)
{
return 1;
}
else
{
return(fibo(n-1)+fibo(n-2));
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the use of data hiding?
Why is it called c++?
Is swift a good first language?
What is a map in c++?
What is a base class?
Out of fgets() and gets() which function is safe to use?
Define a constructor?
Explain terminate() and unexpected() function?
What does override mean in c++?
How is data hiding achieved in c++?
What is c++ virtual inheritance?
What can c++ be used for?
What is the output of the following program? Why?
Explain the scope of resolution operator.
What is auto type c++?