Slot machine program , I am stuck.

So I am trying to program a slot machine but the few problems I have encounters all lie in random number generation my main issue is how do I make truly random numbers between one and six appear on screen and how do I make the computer judge if their is three matchers?

I am not strictly looking for someone just to finish the program I simply want explanations to how I might achieve it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  





int main()
{
int balance = 500;

int fine;

cout << "Welcome to Vegas high roller! Your starting balance is 500 dollars lets play! " << endl;
    std::string start;
    cout << "Type PLAY to spin !" <<endl;
std::cin >> start;

while (start == "PLAY"&& balance > 100){
    cout << "balance:" << balance << endl;
    cout <<"your numerals are" <<endl;
//here is where i wish to put random  numbers


}

}
Last edited on
You won't get a truly random number.
But there are pseudo-randoms:
http://www.cplusplus.com/reference/random/?kw=random
1
2
3
4
5
6
7
8
9
10
11
12
#include <random>
#include <iostream>
using namespace std;

int main()
{
  default_random_engine generator;
  uniform_int_distribution<int> distribution(1,6);
  int result = distribution(generator);
  cout << result;
  return 0;
}
Last edited on
Topic archived. No new replies allowed.