 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can add natural numbers using Vickers and NC. 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 Techimage that is available on Google Play. You can connect with me by following these details which are available in front of you. Now coming on to the topic. I am using Dave C++ for the implementation of code. First of all, I am including a header file that is stdio.h. It is for printf and scanf. After header file includes inclusion, I am declaring a function that is some name of function is some it will return an integer value and its argument type is integer. This statement is known as function declaration. So whenever you want to use a function in C, first you have to declare it then you can define it. After this, I am implementing main function. Inside main function, I am declaring two variables n and s. Then printf statement. Inside printf, I have mentioned enter value of n. So this n will be ending point of the natural number. For example, if n is 10, so I have to add natural numbers starting from 1 to 10. To receive this value from user, I am using scanf. Inside scanf, I have returned %d, %n. The input will be stored inside variable n. Now I have to call some function. This statement is known as function call. I am calling some function argument n is provided as input and the returned value will be stored inside s variable. So the s will receive output value. Now I have to display it on console. This is printf statement which will display the output on console which is received inside s. This is complete definition of main function. After this implementation, I have to implement some function and this some function definition will be recursive. It means this some function definition will be called by itself. So inside this function definition I have to mention function call also. This is known as function definition. Whenever you want to implement recursion, you have to provide two statements. First one is base condition and second one is recursive calling. Base condition is responsible for termination of this function definition repetitive calling and recursive call is responsible for calling this function again and again. First I am implementing base condition which is n w equals to 1. If this condition is true, then value 1 will be returned. Else it will return n plus sum of n minus 1. Friends, this is base condition which is responsible for termination of recursive call and this is recursive function call. Here sum n minus 1. This is recursive function call and it is returned with n plus. So whenever this function will be called, value of n plus will be stored inside stack. So I hope you know that whenever you want to implement recursion, you have to use a data structure that is stacked. So there are the statements which is responsible for recursive calling. If they have additional values or variables, those variables are automatically stored inside stacks so that the complete result can be calculated after base condition will be achieved. Now suppose value of n is 4. So whenever you will be calling this function, 4 will be passed from here. That will be received in function definition. Then if condition is false first time, so return statement n plus sum n minus 1 will be executed. So n is 4. So this statement will convert into this 4 plus sum of 3. Then sum of 3 is again a function call. This 3 will be passed inside this function definition. So this formal parameter will be receiving 3. Then again base condition is false. So return statement will become 3 plus sum of 2. So next function call will be 3 plus sum of 2. So similarly next function call is sum of 2 and will receive 2. Base condition is false. Again recursive call will take place and it will become like this 2 plus sum of 1. When 1 will be passed inside this n variable, this base condition becomes true and it will return 1. So these 4 plus 3 plus n 2 plus all these values automatically stored inside stack like this. These values are stored inside stack and lastly when base condition is achieved, only 1 will return. So 4 plus 3 plus 2 plus 1, all these values are stored inside stack. When base condition is achieved, all these values are calculated and the combined result will be returned at calling statement, which is available inside main function. So this statement is the caller of some function so that final result will be stored inside S with the help of this printf that S will be displayed on console so that output can be displayed for the user. Now I am removing these statements, which are part of explanation. Now I am going to execute this code. So first time compiling it, you can see number of errors and warnings are 0. Now I am executing this. I am entering 4 as input, which is n. You can see some equals to 10. So 1 plus 2 plus 3 plus 4 is equals to 10. So the program is working properly. I hope you have understood how we can add natural numbers starting from 1 to n with the help of recursion in C. This is a demonstration which is having two function definitions. One is main and second one is sum. So whenever you want to implement recursion, you have to remember that first you have to implement functions and then second you don't have to implement loops because recursion itself implement or maintain a loop that will calculate values again and again. So whenever you want to implement any program using recursion, then you have to implement that program with the help of function. So implement this code at your own so that you can understand the concept well. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.