Write C Program to Check Whether the Entered Character is Capital, Small letter, Digit or Any Special Character

What You Should Know?

  • What is if else ladder in c.
  • What is printf() and scanf().

In this post, we will write a simple c program to check whether the entered character is capital, small, digit or any special character. so let’s start our new coding note.

Write C program to check the entered character

#include<stdio.h>
int main() {
   char ch;
   
   printf("\nEnter Any One Character :");
   scanf("%c", &ch);
   if (ch >= '0' && ch <= '9') {
      printf("\nEntered Character is Digit");
   } else if (ch >= 'A' && ch <= 'Z') {
      printf("\nEntered Character is Capital Letter");
   } else if (ch >= 'a' && ch <= 'z') {
      printf("\nEntered Character is Small Letter");
   } else {
      printf("\nEntered Character is Special Character");
   }
return 0;
}

Output :

Enter Any One Character :a
Entered Character is Small Letter
Enter Any One Character :A
Entered Character is Capital Letter
Enter Any One Character :7
Entered Character is Digit
Enter Any One Character :@
Entered Character is Special Character

Leave a Reply

avatar
  Subscribe  
Notify of