C++ Program to Check If a Character is Small, Capital, Number or Special Character andrey среда, 1 октября 2014 г. No Comment

The C++ Program checks if the value entered by a user is a capital, small, number or a special character. The output also returns the Ascii equivalent of the character. IF statement is used for flow of control in the program.

Also Read: C++ Program to Check If a Number Is A Perfect Number or NOt

C++ Program to Find All The Roots Of A Quadratic Equation
C++ Program to Compute The Least Common Multiple of Integers


#include 
int main()
{
char alphabet;

cout<<"enter an character: ";
cin>>alphabet;
int Ascii=alphabet;
if (Ascii>=97 && Ascii<=122)
{
cout<<"the Ascii equivalent of "<" is: "< cout<<"alpabet is a small letter";
}
else if (Ascii>=65 && Ascii<=90)
{
cout<<"the Ascii equivalent of "<" is:" < cout<<"The alphabet is a capital letter";

else if (Ascii>=47 && Ascii<=57)
{
cout<<"the Ascii equivalent of "<"is: "< cout<<"You entered a number";
}
else if (Ascii>=0 && Ascii>=47 || Ascii>=54 && Ascii<=64 || Ascii>=91 && Ascii<=96 || Ascii >=123 && Ascii<=127)
{
cout<<"the Ascii equivalent of "<"is:"< cout<<"you entered a special character";
}
return 0;
}
The C++ Program checks if the value entered by a user is a capital, small, number or a special character. The output also returns the Ascii equivalent of the character. IF statement is used for flow of control in the program.

Also Read: C++ Program to Check If a Number Is A Perfect Number or NOt

C++ Program to Find All The Roots Of A Quadratic Equation
C++ Program to Compute The Least Common Multiple of Integers


#include 
int main()
{
char alphabet;

cout<<"enter an character: ";
cin>>alphabet;
int Ascii=alphabet;
if (Ascii>=97 && Ascii<=122)
{
cout<<"the Ascii equivalent of "<" is: "< cout<<"alpabet is a small letter";
}
else if (Ascii>=65 && Ascii<=90)
{
cout<<"the Ascii equivalent of "<" is:" < cout<<"The alphabet is a capital letter";

else if (Ascii>=47 && Ascii<=57)
{
cout<<"the Ascii equivalent of "<"is: "< cout<<"You entered a number";
}
else if (Ascii>=0 && Ascii>=47 || Ascii>=54 && Ascii<=64 || Ascii>=91 && Ascii<=96 || Ascii >=123 && Ascii<=127)
{
cout<<"the Ascii equivalent of "<"is:"< cout<<"you entered a special character";
}
return 0;
}
by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment