rainmaker simple project

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

#define MAX_RAIN_DROPS 1000

// Function to simulate raindrops falling and count the number of drops caught
int simulateRain(int umbrellaLength);

int main() {
    srand(time(NULL)); // Seed for random number generation
    int umbrellaLength;

    // Get user input for umbrella length
    printf("Enter the length of your umbrella in inches: ");
    scanf("%d", &umbrellaLength);

    // Validate umbrella length
    if (umbrellaLength <= 0) {
        printf("Invalid umbrella length. Please enter a positive value.\n");
        return 1; // Exit with an error code
    }

    // Simulate rain and get the number of drops caught
    int dropsCaught = simulateRain(umbrellaLength);

    // Display the result
    printf("You caught %d raindrops with your %d-inch umbrella!\n", dropsCaught, umbrellaLength);

    return 0; // Exit successfully
}

int simulateRain(int umbrellaLength) {
    int dropsCaught = 0;

    // Simulate raindrops falling
    for (int i = 0; i < MAX_RAIN_DROPS; ++i) {
        int dropLength = rand() % 20 + 1; // Random length between 1 and 20 inches

        // Check if the raindrop is caught by the umbrella
        if (dropLength <= umbrellaLength) {
            dropsCaught++;
        }
    }

    return dropsCaught;
}