Example 9: Determine the Character Type
Learn how to determine the type of character entered.
We'll cover the following
Problem
Write a program that takes a character as an input, and then determine using the ASCII whether the character entered is an upper case alphabet, a lower case alphabet, a digit, or a special symbol. Print your findings on the console.
The ASCII table is given below for your ease.
Character Type | ASCII Value |
---|---|
Uppercase letter | 65 to 90 |
Lower case letter | 97 to 122 |
Digit | 48 to 57 |
Special symbol | 0 to 47, 58 to 64, 91 to 96, 123 to 255 |
Example
Input | Output |
---|---|
4 | digit |
* | special symbol |
R | uppercase letter |
b | lowercase letter |
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.