1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <iostream>
#include <string> // includes go into header
using namespace std;
int getword(string word);
int getvowels(string word);
int main();
{
string word;
getword(word);
getvowels(word);
return 0;
}
int getword(string word);
{
cout<<"Type a word(s): ";
getline(cin,word);
cout<<endl;
return word;
}
int getvowels(string word)
{
int words[100]; // Not needed.
int vowels[6]={"a","e","i","o","u","y"}; // These are chars, not ints
int numofvowels=0;
for(int i=0,i<=100,i++)
{
for(int j=0, j<=6,i++) // The vowel array is 0 to 5, only. And the loops should be separated with ;, not ,
// It's also j++, not i++
{
if (words[i]== vowels[j]) // Not checking the word line.
numofvowels++;
} //vowel for loop
} //word for loop
cout<< "there are "<<numofvowels<<" vowels.";
return 0;
}
|