 Hello friends, I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to explain how you can pass a string into a user defined function. Before start, just for information, if you go to description of this video, you will find links of various playlist related to C-language video. Now, after watching this video, you will get to know how we can process a string with help of user defined function. So for calculation purpose, I'm going to implement a logic through which we will find length of a string. So I will be passing a string into function and that user defined function will be calculating how many characters are available into that string. So input and output of the program will be done into main function and logic will be available in a separate user defined function. So let's understand this. So first I'm going to make a function whose written type is it, name is length and it will be having a parameter whose data type is care and it will be an n. So whenever you pass a string into a function, so string is basically a character array. So that's why we need to put this here. So we are passing one character array. That's why care is evaluated one time. If you want to pass more than one character arrays of string, then use comma and then put more than one or any number of character arrays that you need to pass. The written type is integer because whenever we will be calculating length of any string, so it is always in terms of integer. So that's why written type is n. So don't confuse if you are passing characters or written type will be character always. So written type and argument that we are passing both can be of separate data. Now I'm going to define the function. So let's say this is a string. And here in double codes and passing India as a string, right? So this is initialized here. So I'm not going to read input from user right now. But if you want to read input from user, you can write print depth data or print depth scanner. So input will be available. So for example purpose, I am myself providing input into this program. Then I'm declaring one variable. Let's say L, which will receive length, then L equals to length and inside bracket I am passing string. Now output will be available into this L variable. So I can print it. So length equals to percent B and I am printing L. So this way, here you can see I have completely implemented main function and you can see in this main function, nowhere logic is implemented. Why so? Because logic will be available into this length function definition. So this is the way you can divide your whole program into more than one parts. So first part will be always main that is responsible for reading and printing the output and other functions are responsible for applying the logic, right? So after this, I'm going to implement user defined function so that we can apply the logic. So this will be the block. So this is another block where you need to build your logic, which is for finding length of a string. So here you can see this is the calling statement. This is the calling statement. So control will be transferred to this definition and value of this SDR will be passed to this and this SDR we can use because it will be having all the values which are available in this SDR. So whenever we call a user defined function after calling control transfers to its definition automatically. So this SDR will pass all the values to here. Now we can use this SDR variable for calculation. So here I am declaring these variables and I equals to zero SDR of I not equals to null. So loop will iterate if we don't have null, if null is there then loop will be terminated. And here I'm counting and press this. So after completion of this loop, L will be having total number of characters that are available in this field. So I can write return L. So this will be returned into this L variable. So from calling argument is passed to here then it is processed and through this return keyword we can return this variable back to the calling statement. And then this will be written. Right. So we can say this is the input of the input of the function and this is the output of the function and then it is printed. So you can see this second block is having only logical part and first block that is mainly is responsible for providing input to the spring and output like how many characters are available in that spring to user. So this was the input. And this is how to print this. I'm able to print output on output. So here you can clearly see we have two blocks. This is first block that is made. This is second block. That is another function which is known as grand. So this is a user defined function. And I hope you understood how we can pass string into function. And if you want to watch more programs related to function. So at the end of this video you will find the link related to a playlist functions in C. So open that and you will find all the programs related to user defined functions only into that. So do watch that. And I hope you understood whatever I explained in this video. Thank you for watching.