Given a string and write a C program to count the number of vowels and consonants in this string.
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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Modify string by removing vowels in between two consonants
- Minimum swaps required to move all vowels occurs after consonants in a given string
- Program to count vowels in a string (Iterative and Recursive)
- Program to count vowels, consonant, digits and special characters in string.
- Count consonants in a string (Iterative and recursive methods)
- Program to duplicate Vowels in String
- Program to remove vowels from a String
- Count substrings that contain all vowels | SET 2
- Longest Subsequence of a String containing only vowels
- Remove consecutive vowels from string
- C program to Count the digits of a number
- Count number of Distinct Substring in a String
- C Program to count the Number of Characters in a File
- C Program to count number of lines in a file
- Lex program to count the number of lines, spaces and tabs
- C program to count zeros and ones in binary representation of a number
- C++ program to concatenate a string given number of times
- Program to count number of distinct Squares and Cubes upto N
- Sort an Array of Strings according to the number of Vowels in them
- Check if count of Alphabets and count of Numbers are equal in the given String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.