Kodewick
Start learning →
Mini challenge←→0 / 70

Windowsill plants

#069Mini challengeArraysLoops5 min

Three pots on the windowsill; cm holds how many centimetres each has grown. One line per plant: its name, then as many # as centimetres, like Basil: ###. The name and the newline are already printed.

Should show
Basil: ###
Mint: #####
Chili: ##
main.c
#include <stdio.h>

int main(void) {
    const char *plants[] = {"Basil", "Mint", "Chili"};
    int cm[] = {3, 5, 2};
    for (int i = 0; i < 3; i++) {
        printf("%s: ", plants[i]);
        // your code here: one more loop that prints cm[i] #s
        printf("\n");
    }
    return 0;
}
Ctrl + Enter runs too
Result

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