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
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;
}
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;
}
No Comment