C Program to Check Character is Alphabet, Digit or Special Character

C Program to Check Character is Alphabet, Digit or Special Character

C program to check whether the character is the alphabet, digit, or special character; Through this tutorial, we will learn how to check whether the character is alphabet, digit, or special character.

C Program to Check Character is Alphabet, Digit or Special Character

  • C Program to Check Character is Alphabet, Digit or Special Character using if else
  • C Program to Check Character is Alphabet, Digit or Special Character using Ascii value
  • C Program to Check Character is Alphabet, Digit or Special Character Function

C Program to Check Character is Alphabet, Digit or Special Character using if else

/* C Program to check Character is Alphabet Digit or Special Character */
 
#include <stdio.h>
 
int main()
{
  	char ch;
  	
  	printf(" Please Enter any character :  ");
  	scanf("%c", &ch);
  
  	if( (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') )
  	{
  		printf("\n %c is an Alphabet", ch);  	
 	}
  	else if (ch >= '0' && ch <= '9')
  	{
  		printf("\n %c is a Digit", ch);  	
  	}    
  	else
    	printf("\n %c is a Special Character", ch);
  
  	return 0;
}

The output above c program; as follows:

Please Enter any character :  5
5 is a Digit

C Program to Check Character is Alphabet, Digit or Special Character using Ascii value

#include <stdio.h>
 
int main()
{
  	char ch;
  	
  	printf(" Please Enter any character :  ");
  	scanf("%c", &ch);
  
 	if (ch >= 48 && ch <= 57)
  	{
  		printf("\n %c is a Digit", ch);  	
  	}
  	else if ( (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) )
  	{
  		printf("\n %c is an Alphabet", ch);  	
  	}    
  	else
    	printf("\n %c is a Special Character", ch);
  
  	return 0;
}

The output above c program; as follows:

Please Enter any character :  $
$ is a Special Character

C Program to Check Character is Alphabet, Digit or Special Character using Function

/* C Program to check Character is Alphabet Digit or Special Character */
 
#include <stdio.h>
#include<ctype.h>
 
int main()
{
	char ch;
  	
	printf(" Please Enter any character :  ");
  	scanf("%c", &ch);
  
  	if (isalpha(ch))
  	{
  		printf("\n %c is an Alphabet", ch);  	
  	} 
  	else if (isdigit(ch))
  	{
  		printf("\n %c is a Digit", ch);  	
  	}
  	else
    	printf("\n %c is a Special Character", ch);
  
  	return 0;
}

The output above c program; as follows:

Please Enter any character :  w
w is an Alphabet

Recommended C Programs

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *