Example 76: Count Vowels, Consonants, and Words

Learn how to count vowels, consonants, and words in a string array.

Problem

Write a function that counts vowels, consonants, and words present in a sentence received as an input parameter.

Example

Input Output (V, C, W)
str = “Able was I ere I saw elba” 10, 9,7
str = “Welcome to educative” 9, 9, 3
str = “Learn C” 2, 4, 2

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Note: Do not change the print statement given in the exercise.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.