C program to count number of vowels and consonants in a String
Given a string and write a C program to count the number of vowels and consonants in this string. Examples:
Input: str = "geeks for geeks" Output: Vowels: 5 Consonants: 8 Input: str = "abcdefghijklmnopqrstuvwxyz" Output: Vowels: 5 Consonants: 21
- Take the string as input
- Take each character from this string to check
- If this character is a vowel, increment the count of vowels
- Else increment the count of consonants.
- Print the total count of vowels and consonants in the end.
Below is the implementation of the above approach:
String: geeks for geeks Vowels: 5 Consonants: 8
Time Complexity: O(1)
Auxiliary Space: O(1)