C Program To Accept A Character And Determine Whether Its Number, Alphabet Or Symbol.
Q18. Write a C program to accept a character and determine whether its number, alphabet or symbol.
Solution:
#include<stdio.h> //standard input/output header file
#include<conio.h> //for clrscr()
int main()
{
char a;
clrscr(); //for clearing the screen
printf(“\n Enter any character: “);
scanf(“%c”,&a);
a>=65&&a<=90||a>=97&&a<=122?printf(“\n It is an alphabet.”) : a>=48&&a<=57?printf(“\n It is a number.”):printf(“\n It is a symbol.”);
getch(); //holds the screen until any key is pressed
return 0; //makes main() finish
}
OUTPUT:
CASE 1:
Enter any character: d
It is an alphabet.
CASE 2:
Enter any character: 3
It is a number.
CASE 3:
Enter any character: $
It is a symbol.