Kodewick
Start learning →
Starter←→0 / 70

Letter tiles

#039StarterStringsLoops3 min

The shop spells its sign with letter tiles, and every space needs an empty clip. Write count_spaces(sign) to count the spaces in sign. No spaces gives 0.

Examples
count_spaces("OPEN ALL DAY")→2
count_spaces("TEA")→0
The functionint count_spaces(const char *sign)
main.c
int count_spaces(const char *sign) {
    int n = 0;
    for (int i = 0; sign[i] != '\0'; i++) {
        // your code here: if this character is a space, add 1 to n
    }
    return n;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.