C Program to Generate Fibonacci series using Recursion

Spread the love
In our previous posts we discussed about What is Fibonacci Series?? and Cprogram to generate Fibonacci series. We also written few more programs on Fibonacci series. You can find those programs HERE. Now in this post we are going to write a program to Generate Fibonacci Series but this time using Recursion.

  • Recursion: If A function calls itself then that Function called as Recursive function.

Example :

int fun()
   {
       – – – – – –
      fun(); // Here fun is calling fun so it is Recursive Function.
      — – – – – –
   }

Description :

This Program accept one number from user (Lets say it is n) and prints nth Fibonacci number.

Program :


  1. /* Fib series program using Recursion */
  2. /* Author :  Venkatesh macha */
  3. #include<stdio.h>
  4. int fib( int n)
  5. {
  6.         if(n==0)
  7.                 return 0;
  8.         if(n==1)
  9.                 return 1;
  10.         return(fib(n1)+fib(n2));
  11. }
  12. int main()
  13. {
  14.         int num,nth_fib;
  15.         printf(” Enter which number in Fib series to print : “);
  16.         scanf(“%d”,&num);
  17.         nth_fib = fib(num);
  18.         printf(“%dth Fibnocci number in Fib series is : %d n,num,nth_fib);
  19.         return 0;
  20. }

Output :


OUTPUT of Fibonacci Series Program using Recursion

More programs on Fibonacci Series :

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply