Kodewick
Start learning →
Starter←→0 / 70

Hot days

#028StarterArraysConditions3 min

The top temperature of each summer day is in the array temps, n days in all. Write hot_days(temps, n) to count the days that were 30 degrees or hotter. With n at 0, return 0.

Examples
hot_days({28, 31, 30, 25}, 4)→2
hot_days({}, 0)→0
The functionint hot_days(int temps[], int n)
main.c
int hot_days(int temps[], int n) {
    int count = 0;
    for (int i = 0; i < n; i++) {
        // your code here: if this day was 30 or hotter, add 1 to count
    }
    return count;
}
Ctrl + Enter runs too
Result

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