Just a little help

Hello everyone I am here about a question on an assignment of mine. The question is due tomorrow so please correct my mistake rather than dropping hints. I normally would greatly appreciate it but in this case I am in a bit of a hurry and I promise that I will study my mistake as to where I went wrong.

The questions asks to enter a sentence and in the end be able to portray the amount of vowels, words, upper case letters and lower case letters. Also I must use the part of the vowels in a function using the library <cctype>. I was able to compile all of the other requests except the vowels which Im unsure why. There are no errors in the program but it portrays in the output that there are 0 vowels.
Here is my program

#include <iostream>
#include <iomanip>
#include <cctype>
void VowelSearch (char c, int V);
using namespace std;
int main ()
char c;
int Ul = 0, Ll = 0, W = 1, V = 0;

cout << "I can cout the number of upper case, lower case, vowels and words\n";
cout << "Please enter a sentence: ";
while(cin.get(c), c != '\n')
if(isupper(c)) Ul++;
if(islower(c)) Ll++;
if(isspace(c)) W++;
VowelSearch (c, V);

cout << " No. of upper case letters..........." << Ul << endl;
cout << " No. of lower case letters............" << Ll << endl;
cout << " No. of words............." << W << endl;
cout << " No. of vowels............" << V << endl;

system ("pause");
return 0;

void VowelSearch (char c, int V)
case 'a': case 'e':case 'i':case 'o':case 'u':
case 'A': case 'E':case 'I':case 'O':case 'U':
V++; break;


Thank you so much for the help!!!
First, please you code tags: select all your code and click the '<>' button in the Format options. Make sure that the code is indented properly, too: it makes it easier for us to read and tell you what you have done wrong.

Now, to your question. It makes it easier on yourself (and everyone around you) if you use meaningful names. If that means that your variable names are more than one or two letters long, so be it. But at any rate, your error could be your if statement in VowelSearch: you have a semicolon on the end of your if statement, which means that the switch is executed regardless of whether or not it is a vowel. Also, you need to pass 'V' by reference to increase it as you have done here, otherwise the temporary copy owned by the function will be modified instead, which would lead to no effect in your main function. What would probably better, though, is to instead use something like an isVowel function, which returns true or false, and then increase the 'V' variable by one in that case instead.

Hope this helps!
Topic archived. No new replies allowed.