A Program to Check a Character is Alphabet or Not

In this example, we are giving a program to check a given character is alphabet or not.


Program to check a character is alphabet or not:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. char c;
  6. cout << "Enter a character: ";
  7. cin >> c;
  8. if( (c>='a' && c<='z') || (c>='A' && c<='Z'))
  9. cout << c << " is an alphabet.";
  10. else
  11. cout << c << "is not an alphabet.";
  12. return 0;
  13. }

Output:

Enter a character: F
F is an alphabet