Write a program to check character entered is alphabet, digit or special character using library functions.

Source Code

#include<iostream>
#include<cctype>
using namespace std;

int main()
{
	char ch;
	cout<<"Enter any character :";
	ch=getchar();
	if(isalpha(ch))
		cout<<"Alphabet";
	else if(isdigit(ch))
		cout<<"Number";
	else
		cout<<"Special Character";
	
	return 0;
}


Output

SAMPLE RUN # 1

Enter any character : Z
Alphabet
SAMPLE RUN # 2
Enter any character : 9
Number
SAMPLE RUN # 3
Enter any character : $
Special Character