Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 counterStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started