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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Modify string by removing vowels in between two consonants
- Minimum swaps required to move all vowels occurs after consonants in a given string
- Count consonants in a string (Iterative and recursive methods)
- Program to count vowels in a string (Iterative and Recursive)
- Program to count vowels, consonant, digits and special characters in string.
- Program to remove vowels from a String
- Program to duplicate Vowels in String
- Count substrings that contain all vowels | SET 2
- Remove consecutive vowels from string
- Longest Subsequence of a String containing only vowels
- Minimum cost to convert given string to consist of only vowels
- 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
- Program to count number of distinct Squares and Cubes upto N
- 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 print a string without any quote (singe or double) in the program
- Count Number of animals in a zoo from given number of head and legs
- C Program to count number of lines in a file
- C Program to count the Number of Characters in a File
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.