Example 76: Count Vowels, Consonants, and Words
Learn how to count vowels, consonants, and words in a string array.
We'll cover the following
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.
Get hands-on with 1400+ tech skills courses.