0

Write a OOP in C++ to read a string and find out number of vowels and consonants in that string?

string should be accept from user

6th Apr 2017, 2:10 AM
Damodar Joshi
Damodar Joshi - avatar
4 Respuestas
+ 10
Modify this piece of crap and you'll get what you want. https://code.sololearn.com/cTLVtH9p0iEo/?ref=app
6th Apr 2017, 6:16 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
string word; int vowel, constant; char letter; cout<<"enter a word"; cin<< word; stringstream s(word); while(s<<letter) { switch(letter) { case a: vowel++; break; case e: vowel ++; break; case o: vowel++; break; case i: vowel++; break; case y: vowel++; break; default: constant++; } }
6th Apr 2017, 3:41 AM
chris
chris - avatar
+ 2
if you want to learn about stringstream look at this: https://code.sololearn.com/cxbsvjtABY48/?ref=app
6th Apr 2017, 3:44 AM
chris
chris - avatar
+ 1
make an array containing the vowels. then use a for loop to go through the length of the string. at each character, check if the array contains that character, and if so, increment the vowels counter, else increment the constants counter
6th Apr 2017, 2:27 AM
Edward