C Program To Generating Fibonacci Series Using Recursion

How to write a C Program To Generating Fibonacci Series Using Recursion in C Programming Language ?

Solution For C Program :

/*C Program To Generating Fibonocci Series Using Recursion.*/

#include<stdio.h>
void main()
{
int a, b, j;
int fib(int);
printf("\nEnter N'th Number : "); scanf("%d", &a);
printf("\nPrinting Values of the Fibonacci Series :\n");
for(j = 0; j < a - 1; j++)
{
b = fib(j);
printf("%d,", b);
}
}
int fib(int n)
{
int x, y;
if(n == 0 || n == 1) return (1);
else
{
x = fib(n - 1);
y = fib(n - 2); return(x + y);
}
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable


Learn More :