title: C++ Program to calculate the percent win and loss after x amount of games
body: <p>I am trying to make a program that will calculate the probabilities of winning and losing in the game craps. I got my code to "work", but the win/loss percent should be around ~50%, but I am always getting somewhere around 70-80% instead. I have spent a few hours looking for what I did wrong, and I cannot figure it out. I believe the error is somewhere in the function playGame. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  int rollDice ();
  bool playGame();
  
  
  int main ()
  {
    int number;
    bool outcome;
    int win =0;
    int lose =0;
    int roll;
    double winPercent;
    double losePercent;
    int track =0;
  
    srand(time(0));
  
    cout &lt;&lt; "How many games do you want to play? : ";
    cin &gt;&gt; number;
  
    for (int x =0; x &lt; number; x++)
      {
            track++;
        outcome = playGame();
        if(outcome ==true)
          win++;
        else
          lose++;
      }
    winPercent = (double)win/track*100;
    losePercent = (double)lose/track*100;
  
  
    cout &lt;&lt; setw(8) &lt;&lt; "win %" &lt;&lt; setw(8) &lt;&lt; "lose %" &lt;&lt; endl;
    cout &lt;&lt; setw(8) &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; winPercent  &lt;&lt; setw(8) &lt;&lt; losePercent &lt;&lt; endl;
  
   return 0;
  
  }
  
  int rollDice()
  {
    int roll;
  
    roll = (rand() % 6 + 1) + (rand() % 6 + 1);
  
    return roll;
  
  }
  
  bool playGame ()
  {
    int roll;
    bool winner = true;
    int firstRoll;
  
    firstRoll = rollDice();
  
    if (firstRoll == 7 || firstRoll == 11)
        return winner;
    else if (firstRoll == 2 || firstRoll == 3 || firstRoll == 12)
        return winner = false;
  
    else
      {
       do
         {
           roll = rollDice();
  
         }while (roll != firstRoll &amp;&amp; roll != 7 &amp;&amp; roll != 2 &amp;&amp; roll != 3 &amp;&amp; roll != 3);
    if (roll == 7 || roll == 11 || roll == firstRoll)
        return winner;
    else
     return winner = false;
      }
  }
  </code></pre>