Check whether a character is alphabet or not C Program

Simple C program to check a character whether it is a alphabet or not.

In C/C++ there are 255 characters in which all symbol, alphabets, digits are included. characters are 1,3#/4@#F$?>"Aa. These all are chacters but in alphabets there are 52 alphabets (small and capital). ABCD... and abcd... these are alphabets.

So here we are checking that given character is alphabet or not.

To check run a for loop from a to z and A to Z and increase variable value by one. When we increase alphabets value by one, the ASCII value of alphabets increases by one.

#include<stdio.h>
int main()
{
 char ch;
 printf("Enter a character: ");
 scanf("%c",&ch);
 if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
 {
 printf("Character is alphabet\n");
 }
 else
 {
 printf("Character is not alphabet\n");
 }
 return 0;
}


Popular posts from this blog