I\'m totally newbie here. As stated above, I would like to know how to check whether the input string contains combination of uppercase and lowercase. After that print a stateme
Step 0: variables you need
char* str;
int i;
char found_lower, found_upper;
Step 1: iterate through the string
for (int i = 0; str[i] != '\0'; i++)
Step 2: detect upper and lower case characters
found_lower = found_lower || (str[i] >= 'a' && str[i] <= 'z')
found_upper = found_upper || (str[i] >= 'A' && str[i] <= 'Z')
Step 3: combine the results
mixed_case = found_lower && found_upper
Step 4 (optional) break out of the for
early to save some time
if (found_lower && found_upper) break;
Full source (warning: untested):
char is_mixed(char* str) {
int i;
char found_lower = false, found_upper = false;
for (int i = 0; str[i] != '\0'; i++) {
found_lower = found_lower || (str[i] >= 'a' && str[i] <= 'z');
found_upper = found_upper || (str[i] >= 'A' && str[i] <= 'Z');
if (found_lower && found_upper) break;
}
return (found_lower && found_upper);
}