Question: Coding in C++ and can not seem to figure out how to finish this code I am working on I will post the question as

Coding in C++ and can not seem to figure out how to finish this code I am working on I will post the question as long with some code I have written so far, I would appreciate if you either fix up my code or you can write your own.

Question - The birthday paradox says that the probability that two people in a room will have the same birthday is more than half as long as the number of people in the room (n), is more than 23. This property is not really a paradox, but many people find it surprising. Design a C++ program that can test this paradox by a series of experiments on randomly generated birthdays, which test this paradox for n = 5,10,15,20,...,100. You should run at least 10 experiments for each value of n and it should output, for each n, the number of experiments for that n, such that two people in that test have the same birthday.

#include

#include

#include

using namespace std;

bool check(int d[], int m[], int siz)

{

int count = 0;

for (int i = 0; i

for (int j = 0; j

if (i != j && d[i] == d[j] && m[i] == m[j])

count++;

return count;

}

int main()

{

int bday = 0;

srand(time(NULL));

//int o_day=rand()%31;

//int o_month=rand()%13;

int people[] = { 5,10,20,23,25,50,60,72,80,90,100 };

for (int k = 0; k<10; k++)

{

bday = 0;

cout << k << " experiment :" << endl;

for (int i = 0; i<11; i++)

{

int days[people[i]];

int mths[people[i]];

for (int j = 0; j

{

days[j] = 1 + rand() % 30;

mths[j] = 1 + rand() % 12;

//cout<

}

bday += check(days, mths, people[i]);

cout << people[i] << " have " << bday << " on the same date" << endl;

}

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!