This program is much similar to previous one but here we are checking whether the given character is alphabet, digit or a special character.

Logic

Here first we are checking whether the given character is alphabet or not. If not then check in range 48 (0) to 57 (9) for digit, if it is neither alphabet nor digit then it is absolutely a special character.

See how it is working

Program

#include <stdio.h>

int main() {

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

    if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {

        printf("\n%c is ALPHABET.", ch);

    } else if(ch >= '0' && ch <= '9') {

        printf("\n%c is DIGIT.", ch);

    } else {

        printf("\n%c is SPECIAL CHARACTER.", ch);

    }

    return 0;
}

Output

Enter any character : #
# is SPECIAL CHARACTER.