 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can calculate length of a string 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 Techimage that is available on Google Play. You can connect with me by following these details which are available in front of you. Now I am going to implement the code for you which will count length of string using recursion in C. First of all, I am including a header file that is STDIO.H. Then I am declaring count function. This statement is function declaration. Name of function is count. It will receive an argument of pointer type. So I will be passing base address of the string. That's why I have mentioned character pointer and written type of this function is integer. Now I am defining main function here integer variable C and character array str is available. Now I am creating a printer function which will ask a string from user. With the help of getters function, I am going to read the values from the user inside str string. Now I am calling count function and passing str into it. This statement is known as function call. So count function is called str is passed as an argument. It will pass base address and the result will be stored inside C variable. Now printf statement will display length of string and at last return 0 because written type of main is integer. Now I have to implement definition of this count function. This block is known as function definition and this function will work as recursive function because I will be calling count function inside its definition. So first I am declaring a static variable whose initial value is 0. A static variable are those variables which are not initialized again and again. They use a previous value of a function in their next function call. So after static variable declaration I am implementing a base condition which is if asterisk str equals to null then it will return value of C else C will be incremented and return statement will call count function and inside count I am passing plus plus str. So plus plus str will increase the base address and next character will be checked. So this if condition is base condition. If it is true then recursive process will be terminated. If it is false then counter value will be incremented and this count function will be called. So this calling is recursive function call. This function call will call this function definition count and this process will repeat. If a base condition is true then it will be terminated otherwise counter variable will be incremented. So this is complete implementation which can count the total number of characters which are available in a string or you can say it can find find out length of the string. Now I am executing this code. It is asking for a string. So I am entering my name Sanjay you can see it is printing length of string that is 6 and also remember that here a total size of str is 10. So if you want to enter more than 10 characters then you have to increase this size because this is an static array. So if you want to read the size from the user you can convert it into dynamic array using malloc or calloc functions. So I hope you have understood how we can find out length of a string using recursion in C. Implement this code at your own so that you can understand this concept. If you want to watch more programming related videos you can subscribe my youtube channel that is sanjay gupta underscore tech school. Thank you for watching this video.