Facebook Twitter Google RSS

Thursday, 3 December 2015

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

Tapan     04:54  No comments

#include<iostream.h>
#include<conio.h>

void main()

{      
char ch; clrscr();    
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";

getch();
}



First of all I read a character an then compare it with ASCII values given below.
Uppercase Alphabet: 65-90
Lowercase Alphabet: 97-122
Digit: 48-57
If ASCII value of character is other then the values mentioned above then it is a special character.

, , , , , ,

0 comments :

Popular Post

Website Worth

Contact Us

Name

Email *

Message *

© 2014 BCA Developer. Powered by E Friends.