vowel counter

my program runs but its not showing the number of vowels of the word that the user inputs, anyone have a clue of what im doing wrong

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
51
52
53
54
55
56
57
#include < iostream>
#include <cstring>

using namespace std;

int reverseDigits(char num[], char revNum[], int,int,char let);

int main()
{
	char let=0;
	char letters[10] = {' '};
	char reverseletters[10] = {' '};
	//int multiplier = 1;
	bool isNegative = false;

	cout << "Enter a string: ";
	cin >> letters;

	cout << endl;
	int len = strlen(letters);
	int ind = 0;
	reverseDigits(letters, reverseletters, len, ind,let);



	cout << letters << " after reversal = " 
		<< reverseletters << endl;

	// display vowel count
	cout << "There were "<< let << "vowels in the word.";
	cout << endl;
	system("pause");
	return 0;
	
}

int reverseDigits(char num[], char revNum[],int len, int ind,char let)
{
	
	if (len == 0)
		return let;
	else
	{
		//  if check for vowel
	if (let == 'a' || let == 'e' || let == 'i' || let == 'o' ||let == 'u')
		let++;

 

		len -= 1;
		revNum[ind] = num[len];
		ind += 1;
		reverseDigits(num, revNum, len, ind,let);
	}
	return let;
}
1
2
	int len = strlen(letters);
	int ind = 0;
What's the point of this?

reverseDigits(letters, reverseletters, len, ind,let);
All this does is run the code for the function. You have to set the variable to the return value:

let = reverseDigits(letters, reverseletters, len, ind,let);


You may want to loop through your function.
Last edited on
so I take out
1
2
int len = strlen(letters);
int ind = 0;


what do I do with line 22, because I get errors on
len and ind
Topic archived. No new replies allowed.