Question: Write the following in C program: 1. There's a birthday in our class today! Or will there be two? How likely it is that two
Write the following in C program:


1. There's a birthday in our class today! Or will there be two? How likely it is that two people in one section of our class (40 students have the same birthday? Suggested Approach 1. Prepare an integer array, a 40, to hold birthdays for 40 students. 2. Generate a random number between 1 and 365 and assign the number to each element of all. Use the operator (Example: 300%7 returns the remainder of 300 divided by 7). 3. Compare al0] with the rest of the students' birthdays (i.e. a[1], a[2], a122]) and if there is a match, get out of the loop increment the counter by 1 and go to #2 (the next round of simulation). 4. Compare alij with the rest of the students' birthdays (i.e. a[2], a[3], a122]) and if there is a match, get out of the loop increment the counter by 1 and go to #2 (the next round of simulation). 5. Compare a12] with the rest of the students' birthdays (i.e. a a 4], a122]) and if there is a match, get out of the loop increment the counter by 1 and go to #2 (the next round of simulation). 6. Compare a13] with the rest of the students' birthdays (i.e. a[4], a 5, a1221) and if there is a match, get out of the loop increment the counter by 1 and go to #2 (the next round of simulation). 8. After n simulations, compute the value of counter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
