C program to count number of blank spaces in string

Problem statement

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

Output

Explanation

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.

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.