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++.
2 Answers
+ 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.
0
maybe this would help
https://code.sololearn.com/csEj5VOe6ucB/?ref=app