C program to check whether an alphabet is uppercase or lowercase – In this article, we will detail in on how to check for a character to be an uppercase or lowercase alphabet in C programming.
Only the standard method is going to be used to carry out the same.
Suitable examples and sample programs have also been added so that you can understand the whole thing very clearly. The compiler has also been added with which you can execute it yourself.
The English language has a total of 26 alphabets.
However, there are only two cases of writing or typing namely:
- Uppercase (E.g. A)
- Lowercase (E.g. a)
The uppercase is used at the beginning of a sentence or while expressing a proper noun. The rest of the alphabets are denoted in lowercase only.
Thus, the way to check for an uppercase or a lowercase alphabet in C programming is as follows:
Using Standard Method
1)Read the entered character, store it in the variable ‘ch’.
2)If the ASCII value of the entered character is >=65 and <=90 then it prints “entered character is uppercase”. If the ASCII value is not in the range between 65 to 90 then,
3)Check the ASCII value of the entered character is >=97 and <=122, if the condition is true then it prints “character is lower case” else it prints “character is not an alphabet”.
printf("enter character :");
if(ch>=65 && ch<=90)
printf("character is upper case");
else if(ch>=97 && ch<=122)
printf("character is lower case");
printf("character is not alphabet");
the character is lower case
enter character :A
character is upper case