Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

Below is the C program to check whether the entered Character is uppercase letter, lowercase letter, alphabet, digit or special character.

For that, we will use if-else statement. ASCII value is used to identify the character entered. For example, ASCII value for Uppercase A-Z is 65-90, ASCII value for Lowercase a-z is 97-122, ASCII value for digit 0-9 is 48-57,  and special characters have different series from 0-47, 58-64, 91-96, 123-127.

#include
#include
void main()
{
char ch;
clrscr();
printf("Please enter a character : ");
scanf("%c",&ch); //

if(ch>=97 && ch {
printf("Entered lower case letter.");
}
                else if(ch>=48 && ch {
printf("Entered digit.");
}
                else if(ch>=65 && ch {
printf("\n Entered upper case letter.");
}
else
{
printf("Entered special character.");
}
getch();
}

Output:
Please enter a character : A
Entered Upper case letter.



This post first appeared on Ask For Program, please read the originial post: here

Share the post

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

×

Subscribe to Ask For Program

Get updates delivered right to your inbox!

Thank you for your subscription

×