In this article, we will show you, How to write a C Program to Check the Character is Lowercase or Uppercase Alphabet using built-in functions and ASCII codes.
TIP: In C Programming, there are built-in functions in <ctype.h> header file called isupper, and islower. You can use these functions to check whether the character is a lowercase alphabet or uppercase alphabet.
C Program to Check the Character is Lowercase or Uppercase Alphabet
This program allows the user to enter any character and check whether the character is an uppercase alphabet or not using built-in functions isupper, and islower
/* C Program to check the Character is Lowercase or Uppercase Alphabet */ #include<stdio.h> #include<ctype.h> int main() { char Ch; printf("\n Please Enter any alphabet : "); scanf("%c", &Ch); if ( islower(Ch) ) { printf ("\n Entered character is a Lowercase Alphabet"); } else if ( isupper(Ch) ) { printf ("\n Entered character is an Uppercase Alphabet"); } else { printf("\n Entered character is Not an Alphabet"); } return 0; }
OUTPUT 1
OUTPUT 2
OUTPUT 3
C Program to Check the Character is Lowercase or Uppercase Alphabet Example 2
In this program, we are not using isupper or islower function. Instead of them, we are directly placing alphabets inside the If Statement.
/* C Program to check the Character is Lowercase or Uppercase Alphabet */ #include<stdio.h> int main() { char Ch; printf("\n Please Enter any alphabet\n"); scanf("%c", &Ch); if (Ch >= 'a' && Ch <= 'z') { printf ( "\n Entered character is a Lowercase Alphabet") ; } else if (Ch >= 'A' && Ch <= 'Z') { printf ( "\n Entered character is an Uppercase Alphabet") ; } else { printf("\n Entered character is Not an Alphabet"); } return 0; }
OUTPUT
Let us check with a false value
C Program to Check the Character is Lowercase or Uppercase Alphabet Example 3
In this program, we are using the ASCII codes to check whether the Character is an Uppercase alphabet or lowercase alphabet. I suggest you to refer ASCII Table article to understand the codes.
/* C Program to check the Character is Lowercase or Uppercase Alphabet */ #include<stdio.h> int main() { char Ch; printf("\n Please Enter any alphabet\n"); scanf("%c", &Ch); if (Ch >= 65 && Ch <= 90) { printf ( "\n Entered character is an Uppercase Alphabet") ; } else if (Ch >= 97 && Ch <= 122) { printf ( "\n Entered character is a Lowercase Alphabet") ; } else { printf("\n Entered character is Not an Alphabet"); } return 0; }
OUTPUT
Thank you for Visiting Our Blog