Kodewick
Start learning →
Mini challenge←→0 / 70

Parking fee

#016Mini challengeConditions6 min

The mall car park: the first 2 hours are free, then each hour costs 5, but never more than 30 for the day. Write parking_fee(hours) to return what to pay (hours is a whole number of hours).

Examples
parking_fee(1)→0
parking_fee(4)→10
The functionint parking_fee(int hours)
main.c
int parking_fee(int hours) {
    int fee = 0;
    // your code here: over 2 hours, fee is the extra hours times 5
    // your code here: if fee is over 30, make it 30
    return fee;
}
Ctrl + Enter runs too
Result

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