/* A 'C++' PROGRAM TO FIND Nth FIBONACCI NUMBER USING RECURSIVE FUNCTIONS*/
#include<iostream.h>
#include<conio.h>
int c;
int fibo(int n,int a,int b)
{
if(n-2!=0)
{
c=a+b;
fibo(--n,b,c);
return c;
}
}
void main()
{
clrscr();
cout<<"Enter n value:";
int n;
cin>>n;
if(n==1)
cout<<"\nThe First fibonacci number is :0";
else if(n==2)
cout<<"\nThe second fibonacci number is :1";
else
cout<<"\nThe fibonacci number "<<n<<" is :"<<fibo(n,0,1);
getch();
}
/* OUTPUT
------
Enter n value:10
The fibonacci number 10 is :34
*/
Nice post!!thanks for sharing good post. java vogue have good collection for improve program skill visit Programming Questions And Answers
ReplyDelete