Showing posts with label Fibonacci Series using Recursive Function. Show all posts
Showing posts with label Fibonacci Series using Recursive Function. Show all posts

Tuesday, January 17, 2012

Fibonacci Series using Recursive Function


#include<stdio.h>
#include<conio.h>
int fibo(int,int)
int t1,t2,t3,count;
void main()
{
printf(“enter the number of terms\n”);
scanf(%d”,&n);
t1=0;
t2=1;
printf(%d\t%d”,t1,t2);
count=2;
fibo(t1,t2);
getch();
}
int fibo(int t1,int t2)
{
if(count>=n)
return 0;
else
{
t3=t1+t2;
printf(“\t%d”,t3);
count++;
t1=t2;
t2=t3;
fibo(t1,t2);
}
}



Output:
enter the number of terms
5
0 1 1 2 3