Min Lowercase
Difficulty: ⚫◯◯◯
Tags: array, ascii, characters
Hurdle: Passing this question is sufficient to pass the arrays hurdle.
Description
Write a function min_lowercase that will be passed a character array with exactly size elements. The function should return the lowercase letter with the lowest ASCII value.
Examples
Example 1
Input: {'c', 'A', 'e', 'P', '!'}
Output: 'c'
Explanation: The lowercase letters are 'c' and 'e'. Since 'c' has a lower ASCII value than 'e', return 'c'.
Example 2
Input: {'O', '@', 'g'}
Output: 'g'
Explanation: The only lowercase letter is 'g', so return 'g'.
Example 3
Input: {'z', 'a', 'b'}
Output: 'a'
Explanation: All letters are lowercase. 'a' has the lowest ASCII value (97), so return 'a'.
Function Signature
char min_lowercase(int size, char array[MAX_COLS]);
Constraints
- You can assume that the array has at least 1 lowercase letter.
- You can assume that the array will have at most 100 characters.
min_lowercaseshould not modify the array it is provided.min_lowercaseshould not callscanf,getchar, orfgets.min_lowercaseshould not print anything (do not callprintf).
Hints
- Lowercase letters in ASCII range from 'a' (97) to 'z' (122).
- You can check if a character is lowercase using:
c >= 'a' && c <= 'z'.
Testing
./min-lowercase cAeP!
c
./min-lowercase O@g
g
./min-lowercase zab
a