![]() |
VOOZH | about |
Given a character, the task is to check whether the given character is in upper case, lower case, or non-alphabetic character
Examples:
Input: ch = 'A'
Output: A is an UpperCase character
Input: ch = 'a'
Output: a is an LowerCase character
Input: ch = '0'
Output: 0 is not an alphabetic character
Approach: The key to solving this problem lies in the ASCII value of a character. It is the simplest way to find out about a character. This problem is solved with the help of the following detail:
Implementation:
A is an UpperCase character a is an LowerCase character 0 is not an alphabetic character
Time Complexity: O(1) as it is doing constant operations
Auxiliary Space: O(1)
A is an UpperCase character a is an LowerCase character 0 is not an alphabetic character
Time Complexity: O(1)
Auxiliary Space: O(1)
This implementation uses a switch statement to check the value of the character. If it is an uppercase letter, it will print that it is an uppercase letter. If it is a lowercase letter, it will print that it is a lowercase letter. Otherwise, it will print that it is not an alphabetic character.
A is an UpperCase character a is a LowerCase character 0 is not an alphabetic character
Time Complexity: O(1)
Auxiliary Space: O(1)