Write a program that inputs a character from user and prints whether it is upper case letter, lower case letter, digit or non-letter/non-digit value.
#include <iostream>
int main()
{
char character;
std::cout << "Enter character: ";
std::cin >> character;
if (character >= 'A' && character <= 'Z') {
std::cout << "The entered character is an uppercase letter";
}
else if (character >= 'a' && character <= 'z') {
std::cout << "The entered character is a lowercase letter";
}
else if (character >= '0' && character <= '1') {
std::cout << "Entered character digit";
}
else {
std::cout << "The entered character is not a letter or a number";
}
return 0;
}
Comments
Leave a comment