85: Program to take the value from the user as input any character and check whether it is the alphabet, digit or special character. Using the switch statement.

 

// Program to take the value from the user as input any character and check whether it is the alphabet,
// digit or special character. Using the switch statement.

// *****************************************************************************************************************

#include <iostream>
using namespace std;
int main()
{
    char alpha;
    cout << "Enter a character: ";
    cin >> alpha;

    switch (alpha)
    {
    case 'A'...'Z':
        cout << alpha << " is an uppercase alphabet";
        break;
    case 'a'...'z':
        cout << alpha << " is a lowercase alphabet";
        break;
    case '0'...'9':
        cout << alpha << " is a digit";
        break;
   
    default:
        cout << alpha << " is a special character";
        break;
    }

    return 0;
}


Comments