 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how we can count number of spaces 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 Techimace which is available on Google Play. Now I am going to implement solution of this problem so that you can count number of spaces in a string with the help of function. I am first including a header file that is stdi.h. Now I am declaring a function whose written type is n, name of function is count and it will receive an argument of type character array. So this is function declaration. Now I am defining main function. Inside main, I am declaring a character array and a variable c which is of integer type. Then with the help of printf, I am going to display the message enter string on console to receive input. I am using gathers. So gathers will store all the entered content into str. Now I am calling count function where I am passing str. So this statement is function call. The return value will be received inside c variable. So I can show this, sorry, I can show the value of c variable on console with the help of printf and it is containing number of spaces. So with this printf number of spaces will be displayed on console and then I am writing return zero. This is complete definition of main. Now I am defining count function definition. This block is function definition. Inside this function, I am declaring two variables i and c. C is initialized with zero, which will count number of spaces. Now for logic implementation, I am applying a loop which is initialized with zero. Its condition is str of i not equals to zero and then I plus plus. So this loop will repeat until null occurs. If null is available, then this loop will be terminated. Then I am applying if condition which will check whether the content of string is space or not. If str of i will be equals to space, then c will be incremented by one. So c is counting number of spaces which are available in the string. After completion of this loop, I can return value of c so that it can be received through the variable which is available at function call and then the output can be displayed on console using printf. Now I am executing this code. I am entering Sanjay Kumar Gupta. You can see the output. It is showing number of spaces equals to two. So my name contains two spaces because there are three words. So it is showing correct output. With this way, I have implemented the solution of this problem by passing string into function. I hope you have understood how we can count how many number of spaces are available in the string. If you want to watch more programming related videos, you can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app Techimace which is available on Google Play. Thank you for watching this video.