Kodewick
Start learning →
Basic←→0 / 70

Battery bar

#021BasicLoopsConditions4 min

The battery icon has 5 cells and bars of them are full. The loop goes over the 5 cells: show # for a full one and . for an empty one, all on one line. With bars at 3 it shows [###..].

Should show
[###..]
main.c
#include <stdio.h>

int main(void) {
    int bars = 3;
    printf("[");
    for (int i = 0; i < 5; i++) {
        // your code here: the first bars cells show #, the rest show .
    }
    printf("]\n");
    return 0;
}
Ctrl + Enter runs too
Result

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