Skip to content
Home » Check Character is a lower, upper, digit or special character in C

Check Character is a lower, upper, digit or special character in C

Learn about Check Character is a lower, upper, digit or special character in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Check Character is a lower, upper, digit or special character in C

Source code:

 #include<stdio.h>
 int main()
 {
   char ch;

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

   if((ch >='a' && ch <='z') || ( ch >='A' && ch <='Z') || (ch >='0' && ch <= '9'))
        printf("Digit");
   else printf("Special character.");

   return 0;
 }

Output:

Enter a character: 5
Digit

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Check Eligibility for Marriage in C
Calculate the Net Amount using if else Program in C