 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can calculate some of individual digits of a number using recursion in C. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at bottom right corner of this video. You can download my app Techimus 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, you can see a program which is implemented. This program will calculate some of individual digits of a number. For example, number is 123 so output will be 6 that is 1 plus 2 plus 3. So I have implemented this code with the help of recursion and this program is implemented in C programming language. So first statement is header file inclusion that is STDIO. Second statement is function declaration. Here name of function is sum of digits. It is receiving an argument which is of integer type and it will return an argument or value that is that will be of integer type. Then main method is implemented which is containing two variables num and result. Then printf statement is available. It will be displaying enter and integer number on console. Then scanf statement will read that entered number inside num variable. Then this statement is known as function call. Here sum of digits function is called. Argument num is passed and the result will be stored inside result variable. Then using printf, this result variable will be displayed on console. Then return 0. This is for main function because return type is int. So that's why I have used return 0 statement here. Then sum of digits function is defined. So this is function definition. Inside this function definition, if is containing base condition which is responsible for termination of recursion. So recursion is a process in which a function definition calls itself. So name of function is sum of digits. Here you can see this function is calling itself. So with the help of this calling statement, this function is calling itself. That's why it is implementing recursion. We can say here recursive function call is available. So if num is 0 then it will return 0. Otherwise return num modulus 10 plus sum of digits num upon 10. So this calculation will be stored every time inside the stack and sum of digits function will be called with the help of this notation. Now first I am executing this code so that you can check whether the correct results are displayed or not. Then I will be taking an example so that you can understand this concept well. Now I am executing this code so I am entering 1, 2, 3. You can see it is displaying sum equals to 6. That is 1 plus 2 plus 3. Now let's understand it with detailed explanation. Num is 1, 2, 3 which is received here using scanf. Then a function call has transferred value of num into this num variable. Now base condition is first time false. So this else condition will be executed. So it is saying num modulus 10. So num modulus 10 will provide 3 then plus. So this 3 plus will be stored inside stack and sum sum of digits. This function will be called for num by 10. So num is right now 123. So 123 upon 10 that is equals to 12. So 12 will be passed inside this num. So now new value of num is 12. So 12 is not equals to 0. Again else will be executed. Here num modulus 10 plus. So right now num is 12. So 12 modulus 10 that is 2 plus will be stored inside stack and sum of digits function will be called for 12 by 10. So this time 1 will be passed inside this num. So the current value of num is 1. Again if condition is false. So else will return num modulus 10. So num is 1. 1 modulus 10 is 1. So 1 plus then sum of digits function will be called for num by 10. So 1 by 10 is 0. So this time num is containing 0. So base condition is true. So it will return 0. So this recursion process is terminated and the values which are available inside stack that are 3 plus 2 plus 1 plus 0 and the result will be 6. That will be returned back into this result variable and it is printed with the help of this printf statement on console. So this way this recursive calculation is performing sum of digits of a number. Here 2 function main and sum of digits are implemented. Sum of digits function is a recursive function which is called by main function and main is responsible for reading a number from user and it is displaying the output on the console. So I hope you have understood how we can calculate sum of digits of a number using recursion in C. Implement this code at your own so that you can understand this concept well. If you want to watch more programming related videos you can subscribe my YouTube channel. Thank you for watching this video.