All submissions

Convert Uppercase Letters to Lowercase

Code

#include <stdio.h>
#include <stdint.h>

#define lim(x,min,max) (x>=min) && (x<max+1)
#define isAlpha(x) lim(x,65,90) || lim(x,97,122)
#define isDigi(x) lim(x,48,57)
#define isSymbol(x) lim(x,0,31) || lim(x,33,47) || lim(x,58,64) || lim(x,91,96) || lim(x,123,127)
#define convert_to_lower(x) x = lim(x,65,90)? x+=32 : x 

void to_lowercase(char *str) {
    // Your logic here
    while(*str)
    {
        convert_to_lower(*str);
        str+=1;
    }
}

int main() {
    char str[101];
    fgets(str, sizeof(str), stdin);

    // Remove newline
    uint8_t i = 0;
    while (str[i]) {
        if (str[i] == '\n') {
            str[i] = '\0';
            break;
        }
        i++;
    }

    to_lowercase(str);
    printf("%s", str);
    return 0;
}

Solving Approach

 

 

 

Loading...

Input

Hello Embedded

Expected Output

hello embedded