
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Check input character is alphabet, digit or special character in C
In this section, we will see how to check whether a given character is number, or the alphabet or some special character in C.
The alphabets are from A – Z and a – z, Then the numbers are from 0 – 9. And all other characters are special characters. So If we check the conditions using these criteria, we can easily find them.
Example
#include <stdio.h> #include <conio.h> main() { char ch; printf("Enter a character: "); scanf("%c", &ch); if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) printf("This is an alphabet"); else if(ch >= '0' && ch <= '9') printf("This is a number"); else printf("This is a special character"); }
Output
Enter a character: F This is an alphabet
Output
Enter a character: r This is an alphabet
Output
Enter a character: 7 This is a number
Output
Enter a character: # This is a special character
- Related Articles
- C++ Program to Check Whether a Character is Alphabet or Not
- JAVA Menu Driven Program to Check Character is String, Number or Special Character
- Java Program to Check Whether a Character is Alphabet or Not
- Haskell Program to Check Whether a Character is Alphabet or Not
- How to check whether a character is in the Alphabet or not in Golang?
- Check whether the specified Unicode character is a letter or a decimal digit in C#
- Program to check if a string contains any special character in C
- C# program to check if a string contains any special character
- Java Program to check whether the entered character a digit, white space, lower case or upper case character
- Check whether the Unicode character is a separator character in C#
- C# Program to check if a character is a whitespace character
- Java program to find whether the given character is an alphabet or not
- C++ Program to Check Whether a character is Vowel or Consonant
- Program to check if a string contains any special character in Python
- Check whether a character is Lowercase or not in Java

Advertisements