Code:
#include <iostream>
#include <string>
using namespace std;
bool isVowel(char);
int main ()
{
// Declare variables.
string word;
char ch;
int numOfVowel = 0;
int vowel;
// Get letters from the user.
cout << "Please enter a sequence of letters: " << endl << ">";
cin >> word;
vowel = isVowel(ch);
// Loop to grab all letters.
while (ch != '\n')
{
if (vowel == true)
{
numOfVowel++;
cin.get(ch);
}
}
// Output statment to user with number of vowels found.
cout << "The number of vowels is sequence is: " << numOfVowel << endl;
system("pause");
return 0;
// Function to find the vowels.
}
bool isVowel(char ch)
{
if ('A' == ch || 'a' == ch ||'E' == ch || 'e' == ch ||'I' == ch ||
'i' == ch ||'O' == ch || 'o' == ch ||'U' == ch || 'u' == ch)
{
return true;
}
else return false;
}
Comment