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
4 ответов
+ 10
Modify this piece of crap and you'll get what you want.
https://code.sololearn.com/cTLVtH9p0iEo/?ref=app
+ 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++;
}
}
+ 2
if you want to learn about stringstream look at this:
https://code.sololearn.com/cxbsvjtABY48/?ref=app
+ 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