0
Vowel count
Hey. So I tried this challenge where we need to count the number of vowels in a sentence. Problem: The for loop somehow stops counting after a â â case in the sentence. So e.g. âThis is it.â would return only 1 vowel. I tried many different things but to no avail... Where lies the secret to the solution? Who can help? :) ps: Iâm sure there are a lot of the same questions... havenât checked. Thank you. https://code.sololearn.com/cM29hgouUExG/?ref=app
8 Answers
+ 2
its just how cin works. it'll stop reading if met with whitespace.
try getline
getline(cin,str);
+ 2
https://code.sololearn.com/cotdmW90sW5P/?ref=app
This works.
+ 1
Bobby, length still works fine, either way the loop will terminate once the sentence has been read.
However, 2 issues here that cause Olivia's code to fail:
1. Sololearn will only accept a number as output so code must be cout<<count;
So as nice and practical as her output is it fails the Code Coach.
2. Capitals are also vowels so the vowel[] must also contain A, E, I, O, U
So the inner loop must be at least 10, not 5.
0
See above. ;) sorry used the wrong piece of code first.
0
Olivia
The inner for loop should only loop until 5 instead of lens.
0
Thanks for all the advice! I will try.