i guys,

I'm trying to make a simple Monte Carlo simulation for a class. It requires that I make a roulette game with random numbers.

So far:

There needs to be 1000 games max. You can bet $1 on the game and continue playing until you loose (black and red are wins) .

The statistics are:

Black 0-0.4737

Red Same

Green 0 to .0526.

Because rand() only uses integers. I multiplied the probabilities times 1000.

My code is as follows:

Code:

#include <stdio.h> //std input and output
#include <conio.h>
#include <math.h> //math library
#include <stdlib.h> //standard libarary
int main (void)
{
printf("Welcome To The Roulette Wheel Simulator. \n");
int counter = 0; //count the number of games
int cash = 0; //count the number of $1 you win.
int p = 0; //probability is an integer here to allow for rand.
double probability = 0; //hasn't been used yet.
int games = 0;
//pseudo-random number generator
while (counter <1000) {
counter = counter + 1;
p = rand()%4737+1000;
}
while(p > 526 && counter <1000) //continue to loop until a loss
{
counter = counter + 1; //increment counter.
cash = cash + 1; //add to cash.
}
if(p <= 526)
{
printf("Once you kill a cow, you gotta' make a burger. _GaGa_ \n You lost at %d games\n You won $%d \n", &counter, &cash);
printf ("I knew you'd steal all my honey, you selfish (imagination here). _Beyonce_ \n Press Any Key to Exit says Homer\n");
}
getch();
}

It complies but never prints anything.