Kodewick
Start learning →
Basic←→0 / 70

Star reviews

#047BasicFunctionsLoops4 min

Three reviews gave 3, 5 and 1 stars. The function stars(n) prints a line of n *s; it's void, so it only prints and gives nothing back. Fill in the line inside it, then call it in main for each rating.

Should show
***
*****
*
main.c
#include <stdio.h>

void stars(int n) {
    for (int i = 0; i < n; i++) {
        // your code here: print one *
    }
    printf("\n");
}

int main(void) {
    int ratings[] = {3, 5, 1};
    for (int i = 0; i < 3; i++) {
        // your code here: call stars with this rating
    }
    return 0;
}
Ctrl + Enter runs too
Result

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