I need some help on how to work the GO again and prototypes functions
write a c++ program that asks the user for a single character value, but over and over, for as many character that the user whites to enter. There should be a vowel counter variable that the computer uses to keep track of the number of vowels out of all characters entered. There should be a function called isVowel(char letter) that returns true of the character in letter is vowel, and false otherwise.
this is all i have so far.
char letter;
do {
counter = 0;
do {
enter a letter;
if (isVowel(letter == true)
counter++
}while (GoAgainletter == true)
} while (goAgain(true);
bool isVowel(char letter)
bool x;
x = (my letter == 'a' || (my letter == 'e' || (my letter == 'i' ||(my letter == 'o' ||(my letter == 'u' ||(my letter == 'A' ||(my letter == 'E' ||(my letter == 'I' ||(my letter == 'O' ||(my letter == 'U');
#include <iostream>
#include <cstdlib>
usingnamespace std;
bool isVowel(char c)
{
if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' || c == 'A' || c == 'I' || c == 'U' || c == 'E' || c == 'O') returntrue;
returnfalse;
}
int main()
{
int i;
char c;
int vowel = 0;
do
{
cout << "Enter a character : "; cin >> c;
if(isVowel(c)) vowel++;
cout << "Would you like to enter another character? (Y to continue) : "; cin >> c; cout << endl;
} while(c == 'Y' || c == 'y');
cout << vowel << " character(s) are vowels." << endl;
system("pause");
return 0;
}
Enter a character : a
Would you like to enter another character? (Y to continue) : y
Enter a character : n
Would you like to enter another character? (Y to continue) : y
Enter a character : i
Would you like to enter another character? (Y to continue) : y
Enter a character : m
Would you like to enter another character? (Y to continue) : y
Enter a character : a
Would you like to enter another character? (Y to continue) : y
Enter a character : l
Would you like to enter another character? (Y to continue) : n
3 character(s) are vowels.
cout << " Would you like to enter another sequence of letters? (y/n)";
cin >> c;
}
i tried making this work after the program tells me the vowels . so i can start fresh from the begging of the program but I'm confused. should i place the while loop outside the do.. while loop. or should i leave it apart as its own block?
#include <iostream>
#include <cstdlib>
usingnamespace std;
bool isVowel(char c)
{
if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' || c == 'A' || c == 'I' || c == 'U' || c == 'E' || c == 'O') returntrue;
returnfalse;
}
int main()
{
char c;
int vowel;
do
{
vowel = 0;
do
{
cout << "Enter a character : "; cin >> c;
if(isVowel(c)) vowel++;
cout << "Would you like to enter another character? (Y to continue) : "; cin >> c; cout << endl;
} while(c == 'Y' || c == 'y');
cout << vowel << " character(s) are vowels." << endl;
cout << "Would you like to enter another sequence of letters? (Y to continue) : "; cin >> c; cout << endl;
} while(c == 'Y' || c == 'y');
system("pause");
return 0;
}