Check Character Type (Digit, Alphabet, Special)
C++
Easy
6 views
Problem Description
Identify whether input character is a digit, alphabet, or special character. This uses ASCII value ranges.
Logic: Check ASCII value ranges for classification
Official Solution
void question4_character_type() {
char ch = '9';
if(ch >= '0' && ch <= '9') {
cout << ch << " is a digit" << endl;
} else if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
cout << ch << " is an alphabet" << endl;
} else {
cout << ch << " is a special character" << endl;
}
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!