C++ Program to Check Given Character is Uppercase, Lowercase, Digit or Special Character

Underneath I have shared C++ program to check whether a given character is a capitalized or lowercase letter set, a digit or an exceptional character.

Program

#include<iostream>
 
using namespace std;
 
int main()
{  
	char ch;
	cout<<"Enter any character: ";
	cin>>ch;
 
	if(ch>=65&&ch<=90)
		cout<<endl<<"You entered an uppercase character";
	else if(ch>=48&&ch<=57)
			cout<<endl<<"You entered a digit";
		else if(ch>=97&&ch<=122)
			cout<<endl<<"You entered a lowercase character";
		else
			cout<<endl<<"You entered a special character";
	return 0;
}

Output

Enter any character: F

You entered an uppercase character

As a matter of first importance, I read a character an at that point contrast it and ASCII esteems given underneath.

Uppercase Alphabet: 65-90

Lowercase Alphabet: 97-122

On the off chance that ASCII estimation of character is other, at that point the qualities referenced above then it is an extraordinary character.

Leave a Comment

error: Alert: Content is protected!!