In this tutorial you will learn about the C Program to Check the Character is Lowercase or Uppercase Alphabet and its application with practical example.
C Program to Check Character is Lowercase or Uppercase Alphabet
In this tutorial, we will learn to create a C program that will Check the Character in Lowercase or Uppercase Alphabet in C programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional Statements in C programming.
What is a character?
The character is a single alphabetical entity in the English language and in any word. These letters can be both capital & small or uppercase & lowercase.
For Example:-
In the “Hello” word the there are five characters they are as follows
- “H”
- “e”
- “l”
- “l”
- “o”
Here,
“H” is an uppercase letter.
“e” is a lowercase letter.
“l” is a lowercase letter.
“l” is a lowercase letter.
“o” is a lowercase letter.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declaring the variables for the program. 2. Taking the input character from the user. 3. Passing those variables to conditional statements. 4. Using those conditions to find the case of letter "uppercase" or "lowercase". 5. Printing the result. 6. End Program. |
Program to Check the Character is Lowercase or Uppercase Alphabet
First, will take the character in input from the user. Then will pass that character in the conditional statements to find whether it is an upper case character or in lowercase.
With the help of this program, we can Check the Character in Lowercase or Uppercase Alphabet.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/** * C program to <strong>Check the Character in Lowercase or Uppercase Alphabet</strong><strong>.</strong> */ #include <stdio.h> int main() { /* declaring the variable required for the program. */ char chr; /* Input character from user FOR THE PROGRAM*/ printf("Enter any character: "); scanf("%c", &chr); /* CHECKING THE INPUT FROM THE USER CHARACTER IF ITS LOWER CASE OR UPPER CASE */ if(chr >= 'A' && chr <= 'Z') { //printing the output of the program as upper case. printf("'%c' is an upper case alphabet.", chr); } else if(chr >= 'a' && chr <= 'z') { //printing the output of the program as lower case. printf("'%c' is a lower case alphabet.", chr); } else { //printing the output of the program as not a character. printf("'%c' is not an alphabet.", chr); } return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- chr = it will hold the character value for the input.
Input character from the user.
Finding the character is in upper case or lower case.
Printing output for the program.