In this tutorial you will learn about the C Program to Check Character is Alphabet Digit or Special Character and its application with practical example.
C Program to Check Character is Alphabet Digit or Special Character
In this tutorial, we will learn to create a C program that will Check the Character is Alphabet Digit or Special Character 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 entity in the English language or in any word. These characters can be anything alphabets, digits, special symbols,
In the word “[email protected]”, there are six characters, they are as follows
“W” is an alphabet.
“3” is a digit.
“A, d, d, a” are also alphabets.
“@” is a Special Character.
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 type of character means digits, alphabets,
5. Printing the result.
6. End Program.
Program to check Character is Alphabet Digit or Special Character
First, we will take the input character from the user. Then will pass that character in the conditional statements to find whether the character is the alphabet, digit, special character.
With the help of this program, we can Check the Character with the conditions.
* C program to check alphabet, digit or special character
/* Declaring the variable required for the program */
/* Input character from user */
printf("Enter any character: ");
Checking the Alphabet if it is alphabet
digit or special character.
if((chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z'))
/* Printing the output character as an alphabet */
printf("'%c' is alphabet.", chr);
else if(chr >= '0' && chr <= '9')
/* Printing the output character as a digit */
printf("'%c' is digit.", chr);
/* Printing the output character as a special character */
printf("'%c' is special character.", 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.
Checking the given character is an alphabet, digit, or special character.
Printing output for the program.