Vowel C++ program

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');

return x

}
Last edited on
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
#include <iostream>
#include <cstdlib>
using namespace 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') return true;
	return false;
}

int main()
{
	int i;
	char c;
	int vowel = 0;

	cout << "Enter 30 characters : ";
	for(i = 0; i < 30; i++)
	{
		cin >> c;
		if(isVowel(c)) vowel++;
	}

	cout << vowel << " character(s) are vowels." << endl;
	system("pause");
	return 0;
}
but what if i want the program to asks "would you like to enter another letter ? yes or no"

i know i can use Do.. while loop
but i can't seem to find a way to format it.
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
#include <iostream>
#include <cstdlib>
using namespace 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') return true;
	return false;
}

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.
Last edited on
Nice thanks so far for you're help.

I added some extra features to the program

while (c == 'y') {

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?
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
#include <iostream>
#include <cstdlib>
using namespace 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') return true;
	return false;
}

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;
}
thank you. I got it to work
Topic archived. No new replies allowed.