 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can print Fibonacci series using recursion in C. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at the bottom right corner of this video. You can download my app TechMS that is available on Google Play. You can connect with me by following these details which are available in front of you. For understanding, I am implementing a code so that you can print N terms of Fibonacci series. First I have to include a header file. Then I am declaring a function Fib which will receive an integer as input and it will display or sorry it will return an integer as output. This statement is known as function declaration. Now I am defining main function. Here I am declaring three variables N, I and F. From user I am going to receive value of N. So I have implemented print F with enter value of N masses. Then scan F. It will receive that entered value inside N. Now I am implementing a for loop starting from 0 to N. Inside this for loop I am calling fifth function and argument will be I which will be processed by this fifth function. Result will be stored inside F. So I am going to display that number on console using this print F statement. So this is the implementation of main method. Now I am implementing Fib. Here first base condition is if N is 0 then it will return 0. Else if N is 1 then it will return 1. Otherwise Fib N minus 1 plus Fib N minus 2. This recursive call will be executed. So this will be treated as base condition. This is base condition and it is recursive function call. Here fifth function is called twice. First for N minus 1 and second for N minus 2. So this is complete implementation which will print N terms of Fib series on console. First I am executing this code. It is asking for a number. I am entering 10. You can see it is displaying N terms of Fib series starting from 0, 1, 1, 2, 3, 5, 8 and till 55. In Fib series previous two numbers are added so that new number can be generated. So if we add 3 and 5 new number will be 8. If we add 5, 8 new number will be 13. If we add 8 and 13 new number will be 21 and so on. So this is the code which will print N terms of Fib series on console. Now when this loop will start initially I is 0. So this function call F equals to Fib of I. Here I will be passed inside this function definition. First base condition will become true if N w equals to 0. So it will return 0. That returned value will be received inside F and this print F will print 0 on console. Then I++ will convert value of I from 0 to 1. This time function call will transfer 1. So this base condition will be checked. It is true. So it will return 1. That 1 will be received in F and F will be displayed on console. That is 1. Again I++ will take place right now value of I is 2. So this function call will transfer 2 inside function definition. So first base condition is false. Second base condition is false. So this return statement will be executed. So it is calling Fibonacci function twice. First Fib N minus 1 and second Fib N minus 2. So we have to understand this now. So you can understand it like this at calling Fibonacci of 2. 2 is an argument which is passed. So it is further converted like this. Fibonacci of 1 plus Fibonacci of 0. I have converted it using these function calls. 2 minus 1 is 1. 2 minus 2 is 0. You can see it here. So Fibonacci of 1 will return 1. Then plus and Fibonacci of 0 will return 0. So 1 plus 0 will be returned and that return value will be stored inside F. F will be displayed on console. Then I++ value of I becomes 3. So both the base conditions will be false and again these functions will be called. So this time Fibonacci of 3, this is main function call. So further Fibonacci of 2 and Fibonacci of 1 will be called. Now Fibonacci of 2 will be called further. So it will become Fibonacci of 1 plus Fibonacci of 0. So you can see that Fibonacci of 3 recursive call called Fibonacci of 2 plus Fibonacci of 1. Fibonacci of 2 further called Fibonacci of 1 plus Fibonacci of 0. For Fibonacci of 1 base condition will become true and it will return 1 plus Fibonacci of 0 will return 0. Then for this Fibonacci of 1 it will also return 1. So if we add all these values 1 plus 0 plus 1, result 2 will be returned and that 2 will be received by this F. So this way you can calculate all the terms of Fibonacci series using this recursive method. I hope you have understood how we can implement recursive program to print and terms of Fibonacci series in C. If you want to watch more programming related videos you can subscribe my YouTube channel. Thank you for watching this video.