The output comes out wrong it should be different:

//This is what I have

Enter a sentence: Today Is Thr Jan, 2015
  Number of uppercase letters.........2
  Number of digits....................2
  Number of vowels....................2
Press any key to continue . . .

//The output should look like this:

Enter a sentence: Today Is Thr Jan, 2015
  Number of uppercase letters.........4
  Number of digits....................4
  Number of vowels....................4
Press any key to continue . . .




#include <iostream> 
#include <iomanip> 
#include <string>

using namespace std;

int main()
{
    char c;
    int Uc = 0, Dc=0, Vc=0;
    string vowels("aeiouAEIOU");

    cout << "Enter a sentence: ";
    cin.get(c);
    while(c != '\n')
    {
        {
        if(isupper(c))  
            Uc++;  
        if(isdigit(c)) 
            Dc++; 
        cin.get(c);
        }
        {
        if(vowels.find(c) != string::npos)
            Vc++;
        cin.get(c);
        }
    }
     cout << setfill ('.');
     cout << "  Number of uppercase letters" << right << setw(10) << Uc << endl; 
     cout << "  Number of digits" << right << setw(22) << Dc << endl; 
     cout << "  Number of vowels" << right << setw(22) << Vc << endl;

     system("pause");
    return 0;
}

Each time round the loop you have 2 cin.get(c); lines. I suspect that you only want the one at the end of the loop.

Not sure what exactly you mean?

I'm supposed to get 4, 4, 4 for uppercase, digits, and vowels but its giving me 2, 2, 2 right now

Oh, so you mean like this: ?

    while(c != '\n')
    {
        {
        if(isupper(c))  
            Uc++;  
        if(isdigit(c)) 
            Dc++; 
        if(vowels.find(c) != string::npos)
            Vc++;
        cin.get(c);
        }
    }

Yes, exactly. Does that solve your problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.