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


// Function to generate a random symbol for a reel
char generateSymbol() {
    char symbols[] = {'A', 'B', 'C', 'D', 'E'};
    int index = rand() % 5;
    return symbols[index];
}

// Function to generate a random multiplier for the HayWire feature
int generateMultiplier() {
    return rand() % 5 + 1;  // Generates a random number between 1 and 5
}

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

    printf("Welcome to the HayWire Slot Machine!\n");

    while (1) {
        printf("Press Enter to spin the reels. Type 'exit' to end: ");
        char input[10];
        fgets(input, sizeof(input), stdin);

        if (strcmp(input, "exit\n") == 0) {
            break;  // Exit the loop if the user types 'exit'
        }

        // Spin the reels
        char reel1 = generateSymbol();
        char reel2 = generateSymbol();
        char reel3 = generateSymbol();

        // Display the symbols
        printf("Reel 1: %c\n", reel1);
        printf("Reel 2: %c\n", reel2);
        printf("Reel 3: %c\n", reel3);

        // Check for a winning combination
        if (reel1 == reel2 && reel2 == reel3) {
            printf("Congratulations! You won!\n");

            // HayWire feature: Generate a random multiplier once
            int multiplier = generateMultiplier();
            
            // Print the winning message once with the multiplier
            printf("HayWire: You won %dx the normal payout!\n", multiplier);
        } else {
            printf("Sorry, no match. Try again!\n");
        }
    }

    printf("Thanks for playing the HayWire Slot Machine!\n");

    return 0;
}




Embed on website

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