[Solved] c++ program to check the frequencies of the letters


Update

Assuming that the persons who test your program also enter uppercase text, your program should look like this:

#include <iostream>
#include <iomanip>

using namespace std;

int alpha[26] = {0};

int main(void)
{
    string text;

    cout << "Enter text:" << endl;
    getline(cin, text);

    for (int i = 0; i < text.length(); i++)
    {
        int a = text[i];

        if (a >= 'A' && a <= 'Z')
        {
            alpha[a - 'A']++;
        }
        else if (a >= 'a' && a <= 'z')
        {
            alpha[a - 'a']++;
        }
    }

    cout << "Frequencies:" << endl;

    for (int i = 0; i < 26; i++)
    {
        if (alpha[i])
        {
            cout << right << char('a' + i) << setw(2) << right << alpha[i] << endl;
        }
    }
    return 0;
}

32

solved c++ program to check the frequencies of the letters