Take a string from user and count number of blank spaces in string. And then return count to user as an output.
Program to count blank spaces in string
printf("Enter the string\n");
printf("Number of blank spaces in a string is %d",count);
Enter the string
C is a programming language
Number of blank spaces in a string is 4
In above program we take a string from user and store it in character array a. Then using while loop we fetch each location from string and compare with blank space. Therefore if pointer point to character having value zero then count will increase.
And when string will finish it return value of count which denotes number of blank spaces in string.