C Program to Print Fibonacci Series Using Recursion



A series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.



  1. //C program to print Fibonacci series using recursion
  2. #include<stdio.h>
  3. int Fibo(int);
  4. int main()
  5. {
  6. int a, i = 0, c;
  7. printf(" enter number of elements wanted :");
  8. scanf("%d",&a); // user input
  9. printf("Fibonacci series\n");
  10. for ( c = 1 ; c <= a ; c++ )
  11. {
  12. printf("%d\n", Fibo(i)); //calling the recursive function
  13. i++;
  14. }
  15. return 0;
  16. }
  17. int Fibo(int a) //recursive function Fibo
  18. {
  19. if ( a == 0 )
  20. return 0;
  21. else if ( a == 1 )
  22. return 1;
  23. else
  24. return ( Fibonacci(a-1) + Fibonacci(a-2) );
  25. }

Output
Output!
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


Join Our Facebook Group


Share this example


Download Android App

download android app

Popular C Examples









codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube