title: C++ Birthday Paradox Program
body: <p>I am trying to figure out the Birthday Paradox program for my C++ class. This is what I have so far, but it's not working. I tried looking through other questions about the same topic on here but I'm still pretty lost so any help would be greatly appreciated. </p>
  
  <pre><code>//This program calculates the likelihood of any two people in groups of 2-50 people 
  //having their birthday on the same day, also known as the Birthday Paradox.
  
  #include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
  int people, trial, count = 0, birthdays[50], numMatches, NUM_TRIALS = 5000;
  double total;
  
  //function call
  sameBirthday(birthdays, people);
  numMatches = 0;
  
  for (people = 2; people &lt;= 50; people++)
  {
      //Run trials to see if people have the same birthday
      //Reset number of matches
      numMatches = 0;
      for (trial = 0; trial &lt; NUM_TRIALS; trial++)
      {
          //Randomly generate up to "people" birthdays
          for (int i = 0; i &lt; people, i++)
          {
              birthdays[people] = (rand() % 365) + 1;
              //Check to see if any two people have the same birthday
              for (i = 1; i &lt; people; i++)
              {
                  //birthday one
                  for (int j = 0; j &lt; i-1; j++)
                  {
                      //birthday two
                      for (int k = j +1; k &lt; i; k++);
                  }
              }
          }
      }
  }
  
  bool sameBirthday(int birthdays[], int people)
  {
      //if the two birthdays are the same, add one to the count 
      if (birthdays[j] == birthdays[k])
      {
          people++;
      }
  
      total = (numMatches / 5000.0);
      cout &lt;&lt; "For " &lt;&lt; people &lt;&lt; " people, the probability of two birthdays is about " &lt;&lt; total &lt;&lt; endl;
  
  }
  
  return 0;
  </code></pre>