C Online Compiler
Example: Joyland Ticket Criteria in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Joyland Ticket Criteria #include <stdio.h> int main() { // Step 1: Define the minimum criteria for Joyland tickets const int MIN_AGE = 6; // Minimum age required (in years) const int MIN_HEIGHT = 110; // Minimum height required (in cm) // Step 2: Declare variables to store user input int age; int height; // Step 3: Prompt the user to enter their age printf("Welcome to Joyland Ticket Counter!\n"); printf("Please enter your age (in years): "); scanf("%d", &age); // Step 4: Prompt the user to enter their height printf("Please enter your height (in cm): "); scanf("%d", &height); // Step 5: Evaluate eligibility based on defined criteria if (age >= MIN_AGE && height >= MIN_HEIGHT) { printf("------------------------------------------\n"); printf("Congratulations! You are eligible for a Joyland ticket.\n"); printf("Enjoy your visit!\n"); } else { printf("------------------------------------------\n"); printf("Sorry, you are not eligible for a Joyland ticket.\n"); printf("Reason(s):\n"); // Step 6: Provide specific reasons for ineligibility if (age < MIN_AGE) { printf("- You must be at least %d years old.\n", MIN_AGE); } if (height < MIN_HEIGHT) { printf("- You must be at least %d cm tall.\n", MIN_HEIGHT); } } return 0; }
Output
Clear
ADVERTISEMENTS