0

We were assigned the birthday paradox as a homework assignment. The program intakes a number of people to check and returns the number of people with a shared birthday.

I seem to be having trouble figuring out the loops for the function check_birthdays. I input a number and a number (usually arund 3000) is returned. Any help would be appreictaed!! Have to hand it in tomorrow!!! EEK!

```
#include <iostream>
using namespace std;
#include<time.h>
void check_birthdays (int birthdays[], int num, int count=0)
{
for (int i=0; i<num; i++) //to check each person in the group
{
for (int j=i+1; j<num; j++) //against every other person in the group
{
if (birthdays[i]==birthdays[j])
count++;
}
}
//print out the number of people with same birthday
cout<<"The number of people who share their birthday is "<<count;
}
int main()
{
//create a variable for an inputted number of people
int people, count;
cout<< "Please input a number of people: "<<endl;;
cin>>people;
int birthdays[people];
//input check
if (people<50 || people>100)
cout<<"Error, please try again.";
else
{
for (int i=0; i<people; i++)
{
srand (time (NULL));
birthdays[i]= rand()%365;
}
check_birthdays (birthdays, people, count);
}
}
```