C++ Program for finding whether a character is in Uppercase, Lowercase or is a special character.

Finding whether a Character is Uppercase, Lowercase or Special Character.

Below is a detailed solution to the problem where it has been asked to find out whether the character entered by the user is an Uppercase Letter, a Lowercase Letter or a Special Character. The above can be achieved by comparing the ASCII Code (American Standard Code for Information Exchange) of the corresponding input character. For example, ASCII Code for small letter starts from 97 for ‘a’ and ends at 122 for ‘z’. There’s a difference of 32. 

C++ Program for Uppercase, Lowercase or Special Character



  • Take the input from the user.
  • Use Conditional Statements (If-Else) to determine the range of the ASCII Code for the corresponding Input Character.
  • Write print statements in the respective conditional blocks.

C++ Program

#include <iostream>
using namespace std;
int main()
    char c;
    cout<<"Enter a Character"<<endl;
	    if(48<=c && c<=57)
	        //using ascii codes of digit where 0-48 and 9-57
	    else if(65<=c && c<=90)                  
	        //using ascii codes of capital letters where A-65 and Z-90
	        cout<<"Capital Letter";
	    else if(97<=c && c<= 122)           
	        //using ascii codes of Small letters where a-97 and z-122
	        cout<<"Small Letter";
	        //Rest of the characters ie. special characters
	        cout<<"Special Character";
    return 0;