Kodewick
Start learning →
Starter←→0 / 3

Top score

#002StarterArraysLoops4 min

A quiz: the scores of n people are in the array scores (at least 1). Write top_score(scores, n) to return the highest.

Examples
top_score({72, 95, 88}, 3)→95
top_score({60}, 1)→60
The functionint top_score(int scores[], int n)
main.c
int top_score(int scores[], int n) {
    int best = scores[0];
    for (int i = 1; i < n; i++) {
        // your code here: if it is bigger than best, keep it instead
    }
    return best;
}
Ctrl + Enter runs too
Result

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