0

Input a string and give the no. of vowels and also displays them in the output screen.

Please give the program which satisfies the above ques. in c++.

27th Aug 2017, 2:56 PM
Arshiyan Rahman
Arshiyan Rahman - avatar
2 Réponses
+ 1
int vowels = 0; string input; getline (cin, input); for (auto i : input) { if (i == 'a' || i == 'e' || i == 'i' || i == 'o' || i == 'u') { vowels++; cout << i << " "; } } cout << "\nThere are " << vowels << " vowels."; This doesn't account for upper and lower case, so you should force it into either for the if statement. For mine, I would need to force it into lower case.
27th Aug 2017, 3:13 PM
Zeke Williams
Zeke Williams - avatar
27th Aug 2017, 3:17 PM
Rishabh Agrawal
Rishabh Agrawal - avatar