C Program To Print Fibonacci Series using Recursion
Here’s a C Program To Print Fibonacci Series using Recursion Method. This Code To Generate Fibonacci Series in C Programming makes use of If – Else Block Structure. Recursion method seems a little difficult to understand. The Fibonacci Sequence can be printed using normal For Loops as well. The Recursive Function must have a terminating condition to prevent it from going into Infinite Loop.
What is Fibonacci Series?
A Fibonacci Series is a Sequence of Numbers in which the Next Number is found by Adding the Previous Two Consecutive Numbers. The First Two Digits are always 0 and 1.
A Fibonacci Series consists of First Digit as 0 and Second Digit as 1. The Next Digit (Third Element) is dependent upon the Two Preceding Elements (Digits). The Third Element so, the Sum of the Previous Two Digits. This addition of previous two digits continues till the Limit.
Note: The First Two Digits in a Fibonacci Series is always 0 and 1.
0 1 1 2 3 5 8
C Program To Print Fibonacci Series using Recursion Method
int fibonacci(int x);
int limit, res, count;
printf("\nEnter the Number of Elements to be Printed:\t");
for(count = 0; count < limit; count++)
printf(" %d ", fibonacci(count));
int fibonacci(int x)
if(x == 0||x == 1)
return (fibonacci(x - 1) + fibonacci(x - 2));
In case you get any Compilation Errors with this C Program To Print Fibonacci Series with Recursion method or if you have any doubt about it, mention it in the Comment Section.