C PLEASE cctype functions Write a program that counts the nu

C++ PLEASE

(cctype functions).

Write a program that counts the number of vowels present in a line of text. The line is read from the user. The count of the vowels is written to the user.

Note: Your program must count vowels in lower case or in upper case (use cctype library).

Input line:

American University of Sharjah.

Output:

aCount = 4

eCount = 2

iCount = 3

oCount = 1

uCount = 1

Solution

main.cpp

#include <iostream>
using namespace std;

int main()
{
    char line[150];
    int aCount,eCount,iCount,oCount,uCount;
    aCount = eCount = iCount = oCount = uCount = 0;

    cout << \"Enter a line of string: \";
    cin.getline(line, 150);
    cout<<endl;
    for(int i = 0; line[i]!=\'\\0\'; ++i)
    {
        if(line[i]==\'a\' || line[i]==\'A\')
        {
            ++aCount;
        }
        else if(line[i]==\'e\' || line[i]==\'E\')
        {
            ++eCount;
        }
        else if(line[i]==\'i\' || line[i]==\'I\')
        {
            ++iCount;
        }
        else if (line[i]==\'o\' || line[i]==\'O\')
        {
            ++oCount;
        }
        else if (line[i]==\'u\' || line[i]==\'U\')
        {
            ++uCount;
        }
    }

    cout << \"aCount: \" << aCount << endl;
    cout << \"eCount: \" << eCount << endl;
    cout << \"iCount: \" << iCount << endl;
    cout << \"oCount: \" << oCount << endl;
    cout << \"uCount: \" << uCount << endl;

    return 0;
}

Output:-

C++ PLEASE (cctype functions). Write a program that counts the number of vowels present in a line of text. The line is read from the user. The count of the vowe
C++ PLEASE (cctype functions). Write a program that counts the number of vowels present in a line of text. The line is read from the user. The count of the vowe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site