I am trying to write a simple slot machine program that will return three numbers as the slot icons using a loop. I can get the first part just fine (I think). But I am stuck at converting my icons to intergers or character that I can compare to see if it is a winner or not. Here so far:
// slot machine
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int Win1 = 0, Win2 = 0, Win3 = 0;
srand (time(0)); // seed random number generator based on time
/* creating a counter and loop to generate three
random numbers */
int c; // create a counter
for (c = 0; c < 3; c++) //initialize, test and update the counter
{
int random = rand(); // generate random number
int Win = (random % 3) + 1; // constrain random number between 1 and 3
cout << Win << " ";
}
return 0;
}
I have tried to add the following to my loop without success:
if (c ==1 )
Win1 = Win;
if (c == 2)
Win2 = Win;
if (c == 3)
Win3 = Win;
I was then going to usr the integers Win1, Win2 etc to make my comparisons but it doesn't work. I feel like I am missing something very simple.