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


Please Help Members By Posting Answers For Below Questions

What is the history of c++?

563


Can you help me with this one? Make a program that when a user inputed a Product Name, it will display its price, and when the user inputed the quantity of the inputed product, it will show its total price. The output must be like this: Product Name: Price: Quantity: Total Price: ..this is the list of products to be inputed: Cellphone - 1500 Washing Machine - 5200 Television - 6000 Refrigirator - 8000 Oven - 2000 Computer - 11000 thanks..:D

3073


Explain the concept of copy constructor?

626


Is c better than c++?

625


Explain dangling pointer.

684






What are the two types of polymorphism?

600


What is class definition in c++ ?

639


Explain the concept of memory leak?

635


Evaluate !(1&&1||1&&0) a) Error b) False c) True

708


What is lambda in c++?

582


Difference between inline functions and macros?

605


What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required

577


What is auto used for in c++?

575


What are manipulators in c++ with example?

593


What is the full form of india?

573