C program to check whether a character is alphabet, digit or special character

Introduction

C program to check whether a character is alphabet, digit or special character. I have used DEV-C++ compiler for debugging purpose. But you can use any C programming language compiler as per your availability.

#include <stdio.h>
int main()
{     
   char ch;
 
    printf("Enter any character: ");
    scanf("%c", &ch); 
 
    // Alphabet checking condition
    if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
    {
        printf("%c is an Alphabet.", ch);
    }
    else if(ch >= '0' && ch <= '9')
    {
        printf("%c is a Digit.", ch);
    }
    else
    {
        printf("%c is Special character.", ch);
    } 
    return 0;   
}

Result

C program to check whether a character is alphabet, digit or special character
C program to check whether a character is alphabet, digit or special character

Leave a Comment

x