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 <stdio.h>
  2. int main()
  3. {
  4. char c;
  5. printf("Enter a character: ");
  6. scanf("%c",&c);
  7. if( (c>='a' && c<='z') || (c>='A' && c<='Z'))
  8. printf("%c is an alphabet.",c);
  9. else
  10. printf("%c is not an alphabet.",c);
  11. return 0;
  12. }

Output:

Enter a character: F
F is an alphabet