#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

double ticketPrice(int age, double price, bool welfare){
    if(age < 0){
        fprintf(stderr, "Age cannot less than 0!");
        exit(EXIT_FAILURE);
    } else if(age < 11){
        return 0;
    } else if(age <= 18){
        return price*0.75;
    } else if(age <= 120) {
        if(welfare){
            return price*0.75;
        } else {
            return price;
        }
    } else {
        fprintf(stderr, "Age cannot greater than 120!");
        exit(EXIT_FAILURE);
    }
    
}

int main() {
    printf("%lf\n", ticketPrice(20, 100.0, 0));
    printf("%lf\n", ticketPrice(15, 200.0, 0));
    printf("%lf\n", ticketPrice(25, 500.0, 1));
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: