In this tutorial you will learn about the C Program to Check Whether Character is Uppercase or Not and its application with practical example.
C Program to Check Whether Character is Uppercase or Not
In this tutorial, we will learn to create a C program that will Check Whether Character is Uppercase or Not in C programming.
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.
In the “Hello” word the there are five characters they are as follows
Hence, “H” is a capital letter/ uppercase letter.
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 Whether Character is Uppercase or Not
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 not.
With the help of this program, we can Check Whether the Character is Uppercase or Not.
* C program to check whether a character is uppercase or NOT
/* declaring the variable required for the program. */
/* Input character from user FOR THE PROGRAM*/
printf("Enter any character: ");
/* CHECKING THE INPUT FROM THE USER CHARACTER IF ITS UPPER OR LOWER CASE */
if(chr >= 'A' && chr <= 'Z')
//printing the output of the program as upper case.
printf("'%c' is uppercase alphabet.", chr);
else if(chr >= 'a' && chr <= 'z')
//printing the output of the program not a upper case.
printf("'%c' is not uppercase alphabet.", chr);
//printing the output of the program as not a character.
printf("'%c' is not an alphabet.", chr);
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 not.
Printing output for the program.