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

18th Jun 2020, 1:17 PM
The_Fox
The_Fox - avatar
8 ответов
+ 2
its just how cin works. it'll stop reading if met with whitespace. try getline getline(cin,str);
18th Jun 2020, 1:40 PM
Taste
Taste - avatar
18th Jun 2020, 2:00 PM
Olivia
Olivia - avatar
+ 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.
5th Nov 2022, 10:46 AM
Scott D
Scott D - avatar
0
See above. ;) sorry used the wrong piece of code first.
18th Jun 2020, 1:34 PM
The_Fox
The_Fox - avatar
0
Olivia The inner for loop should only loop until 5 instead of lens.
18th Jun 2020, 2:23 PM
Bobby Fischer
Bobby Fischer - avatar
0
Thanks for all the advice! I will try.
18th Jun 2020, 2:27 PM
The_Fox
The_Fox - avatar