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

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

  
#include <stdio.h>
int main()
{
    char ch;
    printf("Enter any character: ");
    scanf("%c", &ch);
    
    if((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90))
        printf("'%c' is alphabet.", ch);
    else if(ch >= 48 && ch <= 57)
        printf("'%c' is digit.", ch);
    else 
        printf("'%c' is special character.", ch);
    
    return 0;
}

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


#include 

int main()
{
 char ch;

    printf("Enter any character: ");
    scanf("%c", &ch);


    
    if((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90))
        printf("'%c' is alphabet.", ch);
    else if(ch >= 48 && ch <= 57)
        printf("'%c' is digit.", ch);
    else 
        printf("'%c' is special character.", ch);
    

    return 0;
}

Output

Enter any character: H                                                                                                
'H' is alphabet. 
Compile and Run Online