dimanche 4 septembre 2022

How do I use the rand functions output in C++?

I am trying to create a slot machine where I have to generate 3 random numbers from 2 - 7 and then use that output to give different outcomes. For example if the output is 777 and then your bet gets multiplied by 10, if it's 222 then it gets multiplied by 5. I can't seem to get the output of the rand function into a variable to use it and its not calculating properly.

Code:

This is not the full code

if (bet <= 2000)
    {
        std::cout << endl;

        int game_num = 0;
        srand (0);
        for (int i = 0; i < 3; i++)
        std::cout << (rand() % 1) + 2;
        std::cout << endl;

        if (game_num == 777)
        {
            bet = bet * 10;
            std::cout << "You Won: " << bet << endl;
            return 0;
        }

        else if (game_num == 222 || 333 || 444 || 555 || 666)
        {
            bet = bet * 5;
            std::cout << "You Won: " << bet << endl;
            return 0;
        }



Aucun commentaire:

Enregistrer un commentaire