#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("\n\nWelcome To The Haywire Slot Machine ! ");

    while(1) {
        printf("\n\n\n\n\nPress Enter to spin Reels. Press 'exit' to end: \n\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("\n\n\n\n\nCongratulations ! You won ! ");

            int multiplier = generateMultiplier();

            printf("\n\n\nHaywire ! ! ! You won %dX the normal payout ! \n\n\n", multiplier);            
        } else {
            printf("\n\n\nSorry, no match. Try again \n\n\n");

            printf("\n\n\nThanks for playing ! \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: