Kodewick
Start learning →
Starter←→0 / 70

Reading month

#027StarterArraysLoops3 min

Reading month is over: the number of books each of n classmates read is in the array books. Write total_books(books, n) to return how many the class read in all. Nobody (n is 0) gives 0.

Examples
total_books({3, 5, 2}, 3)→10
total_books({}, 0)→0
The functionint total_books(int books[], int n)
main.c
int total_books(int books[], int n) {
    int total = 0;
    for (int i = 0; i < n; i++) {
        // your code here: add the i-th classmate's books to total
    }
    return total;
}
Ctrl + Enter runs too
Result

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