 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can count number of words available in a string by passing string into function. Before starting, you can note my information, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app Techimps which is available on Google Play. Now first we have to understand the concept of word, how we can count number of words in a string. So here you can see a statement or sentence is available in front of you. So here count is a word because it is terminated by space. So whenever a collection of character is terminated by space, then it becomes word. So here count is word, number is another word, then off, then words. Here if I count this statement, then total 11 words are available. Now count number of spaces. So here one space between count and number, second space is available between number and off. So here if you count, total number of spaces are 10. So in a sentence, if number of spaces are n, then n plus 1 words will be available. So to find out number of words, I have to count number of spaces. Then I will be adding one into number of spaces. Then I will be able to count number of words which are available in the sentence or in a string. Now I am going to implement how we can count these number of words with the help of C program. For that purpose, first I am including a header file. Then I am declaring a function whose name is count. Its return type is integer and it will receive an argument of type character array. And this is function declaration. Now I am defining main function. Inside main, I am declaring a character array and then a variable C which will receive the counted value. Now with the help of printf, I am going to display the message enter string on console. My message will be received by GATUS inside str function. Now I am calling count function and I am passing str into it. So this statement will be known as function call. After receiving value into C variable, I can print number of words equals to percenty and then C. At last, I am writing return zero. So this is the definition of main function. Now I am implementing definition of count. This block will be known as function definition. Now I am declaring two variables, I and C. To count number of spaces, I am applying a loop. Here you can see I have initialized loop with zero. Its condition is str of I not equals to zero. So if this condition is true, it means string is not containing null. Then it will repeat if null occurs, then this loop will be terminated and then I++. Now inside for loop, I am applying if condition str of I W equals to space and then C++. So if str of I is equals to space, then C will be incremented by one. After completion of this loop, C will be counting how many spaces are available in the string. After completion of this counting, I can add one into C because number of words are equals to number of spaces plus one. So if number of spaces are 10, then I have to add one into it. Then number of words will be 11. Now I can return value of C. So this way I have implemented the complete code in front of you. I am modifying size of string to 30 because I need to enter more than 10 words while I will be executing this code. So I am executing this code now. I am entering Sanjay Kumar Gupta. So this is my full name. So here you can see I have entered spaces two times. So number of words are three. Now you can see the output number of words equals to three. So the program is working properly. It is counting first number of spaces. Then one is added to number of spaces so that this program is finding out how many words are available. I hope you have understood how we can pass string into function to count number of words which are available in a string. If you want to watch more programming related videos, you can follow or subscribe my YouTube channel through the URL youtube.com. You can download my programming app Techimace which is available on Google Play. Thank you for watching this video.