How to count consonants after vowel in a string but not after a consonant | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to count consonants after vowel in a string but not after a consonant

Ex:Ooprtuh No.of consonants=2

30th Sep 2021, 5:42 PM
yamuna murari
yamuna murari - avatar
5 Answers
+ 1
Which is it, c, c++, or Java?
30th Sep 2021, 5:53 PM
Simon Sauter
Simon Sauter - avatar
+ 1
In general: Make a list of vowels and a list of consonants. Loop through the letters of your string. If a letter is in the list of consonants check if the letter before is in the list of vowels, if it is increase the count.
30th Sep 2021, 5:56 PM
Simon Sauter
Simon Sauter - avatar
+ 1
You can use ASCII values with loop as well...Here is an example for you https://code.sololearn.com/c7aaxB8xDXWX/?ref=app Hope it helps :)
30th Sep 2021, 7:26 PM
Rupali Haldiya
Rupali Haldiya - avatar
0
U can define vowel in array if u dont want to write then u need to write big expression in if else condition . u need to check if entered char is match with vowel or not if not then in else part you can use one counter variable which will count the number of iterations. Logic is simple u can take string as a input and store in char array then check index 0 is vowel or not and use counter do same for all or u can also count all the vowels and subtract with the total lenght of string - total number of vowela remaining are consonent
30th Sep 2021, 6:41 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Yamuna Murari, I have the code ready, but I'll be waiting for you to give it a try first, and share your code link here.
1st Oct 2021, 3:07 PM
Ipang