codescracker


c

C Program to Check Alphabet or Not



« Previous Program Next Program »


Check Alphabet or Not in C

To check whether the input character is an alphabet or not alphabet in C programming, you have to ask to the user to enter a character and start checking for alphabet with ASCII values. If character has ASCII values between 65 to 92 or between 97 to 122, then it will be an alphabet. Otherwise, it will not be an alphabet. You can also check whether the character is in between a to z(alphabet) or A to Z(alphabet) or not(not alphabet)

C Programming Code to Check Alphabet or Not

Following C program ask the user to enter a character to check whether it is an alphabet or not, then display the output on the screen:

/* C Program - Check Alphabet or Not */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	char ch;
	printf("Enter a character: ");
	scanf("%c",&ch);
	if((ch>='a'&& ch<='z') || (ch>='A' && ch<='Z'))
	{
		printf("%c is an alphabet",ch);
	}
	else
	{
		printf("%c is not an alphabet",ch);
	}
	getch();
}

When the above c program is compile and executed, it will produce the following result. Above C Programming Example Output (for alphabet - lowercase):

c program check alphabet or not

Above C Programming Example Output (for alphabet - uppercase):

c program alphabet

Above C Programming Example Output (for not alphabet - number):

alphabet c program

Above C Programming Example Output (for not alphabet - special character):

alphabet program c

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test