C Program to Print Fibonacci Series using Recursion

In this program, you’ll learn to Print the Fibonacci Series in C using Recursion.

 

#include<stdio.h>
#include<conio.h>
int a,n,count,x,y,z;
int fibo(int a, int b);
void main()
{
clrscr();
printf("How many terms you want to print?\n");
scanf("%d",&n);
x=0;
y=1;
printf("First %d terms in Fibonacci series are:",n);
printf("%6d%6d",x,y);
count=2;
fibo(x,y);
getch();
}
int fibo(int x, int y)
{
if(count>=n)
return;
else
{
z=x+y;
printf("%6d",z);
count++;
x=y;
y=z;
fibo(x,y);
}
}

 

Output:

C Program to Print Fibonacci Series using Recursion