#include<iostream.h>
#include<conio.h>
void main()
{
char ch; clrscr();
cout<<"Enter any character: ";
cin>>ch;
if(ch>=65&&ch<=90)
#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";
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 :