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


char generateSymbol() {
    char symbols[] = {'A', 'B', 'C', 'D', 'E'};
    int index = rand() % 5;
    return symbols[index];
    
}


int generateMultiplier() {
    return rand() % 5 + 1;
    
}


int main() {
    srand(time(NULL));

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

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

        if(strcmp(input, "exit\n") == 0) {
            break;
        }

        char reel1 = generateSymbol();
        char reel2 = generateSymbol();
        char reel3 = generateSymbol();

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


        if(reel1 == reel2 && reel2 == reel3) {
            printf("Congratulations! You won!\n");

            int multiplier = generateMultiplier();

            printf("Haywire: You won %dx the normal payout!\n\n\n", multiplier);
        } else {
            printf("Sorry, no match. Try again!\n\n\n");
        }
    }
    printf("Thanks for playing the Haywire Slot Machine!\n\n\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: