C++ Exercises: Count the letters, spaces, numbers and other characters of an input string.
86. Count Letters, Spaces, Numbers, and Others in a String
Write a C++ program to count the letters, spaces, numbers and other characters in an input string.
Visual Presentation:

Sample Solution:-
C++ Code :
Sample Output:
Count the letters, spaces, numbers and other characters: ------------------------------------------------------------- Enter a string: This is w3resource.com The number of characters in the string is: 22 The number of alphabets are: 18 The number of digits are: 1 The number of spaces are: 2 The number of other characters are: 1
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C++ program to count the number of alphabets, digits, spaces, and special characters in an input string.
- Write a C++ program that reads a string and outputs a summary of character types by iterating through each character.
- Write a C++ program to analyze a string and display the frequency of letters, digits, and non-alphanumeric characters.
- Write a C++ program to process an input string and print a report showing counts for alphabets, numbers, whitespace, and others.
C++ Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a program in C++ to reverse a string.
Next: Write a program in C++ to create and display unique three-digit number using 1, 2, 3, 4. Also count how many three-digit numbers are there.
What is the difficulty level of this exercise?