Kodewick
Start learning →
Basic←→0 / 70

Playlist backwards

#031BasicArraysLoops4 min

The playlist has 4 songs and today you want them backwards. The loop's i counts from 0 to 3; each time show one song title (%s), one per line, starting with the last song, Goodnight.

Should show
Goodnight
Road Trip
Rainy Day
Sunrise
main.c
#include <stdio.h>

int main(void) {
    const char *songs[4] = {"Sunrise", "Rainy Day", "Road Trip", "Goodnight"};
    int n = 4;
    for (int i = 0; i < n; i++) {
        // your code here: show the (i + 1)-th song from the end
    }
    return 0;
}
Ctrl + Enter runs too
Result

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