C Program to Check Whether a Character is Alphabet, Digit or Special Character ?
Q:- Write a C Program to Check Whether a Character is Alphabet, Digit
or
Special Character ?
Input
#include<stdio.h>
#include<conio.h>
int main()
{
char ch;
clrscr();
printf(“Enter a Character = “);
scanf(“%c”,&ch);
if(ch>=’a’ && ch<=’z’
|| ch>=’A’ && ch<=’Z’)
{
printf(“%c is Alphabet.”,ch);
}
else if(ch>=’0’ &&
ch<=’9’)
{
printf(“%c is Digit.”,ch);
}
else
{
printf(“%c is Special Character.”,ch);
}
getch();
}
Output
Enter a
Character = f
f is Alphabet.
Comments
Post a Comment