Write a program in C to print 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);
}
}
Post a Comment