Birthday Paradox Assignment with Menu (C++)
<p>I'm a computer programming student in my second semester. Passing functions by value/reference is still something I'm struggling with. The following code generates a random set of 23 birthdays and tests for a match successfully. The problem is calling this function 1000 times to test the percentage of birthday matches.</p>

<p>I've tried a few different approaches, passing an int from main() to this function by reference, so whenever a match is found it increments this by 1. The other method I tried is creating an int inside the function set to 0. If a match is found this int is changed to 1 and returned. Any help would be greatly appreciated!</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;ctime&gt;
#include &lt;cmath&gt;
#include &lt;cstdlib&gt;

using namespace std;

int SortedArray();

int main(){

    srand(time(0));

    int count = 0;
    const int Columns = 23;

    for(int h=1; h&lt;1000; h++){
        SortedArray();
        if(SortedArray() == 1){
            count++;
        }
    }
    cout &lt;&lt; count;
}


int SortedArray(){

    int MatchCount;
    int RandomSet[24] = {0};
    const int Columns = 24;


    for (int i=1; i &lt; Columns; i++){
        RandomSet[i] = (rand()%366);
            if (RandomSet[i] == 0){
                RandomSet[i] = RandomSet[i] + 1;
            }
    }

    for (int l=0; l &lt; Columns; l++){
        for (int k=1; k &lt; Columns; k++){
            for (int j=1; j &lt; Columns; j++){
                int Temp = 0;
                if (RandomSet[j] &gt; RandomSet[j+1]){
                    Temp = RandomSet[j];
                    RandomSet[j] = RandomSet[j+1];
                    RandomSet[j+1] = Temp;
                }                   
            }
        }

        if(RandomSet[l] == RandomSet[l+1]){
                MatchCount = 1;
        }

    }   

return MatchCount;
}
</code></pre>