Question: Write a c program that will simulate the following random events using the rand( ) function in the C standard libraries. We are interested in

 Write a c program that will simulate the following random events using the rand( ) function in the C standard libraries. We are interested in determining if rand( ) really seems to produce a random set of values. To do this we will repeat the event a certain number of times and see how often we get each of the possible results. If rand( ) is truly random, and our mapping to the possible results is uniform, our results should be equally likely and therefore evenly distributed across all possible results. We will simulate the following three events: 1) Flipping a coin 2) Rolling a six-sided die 3) Drawing one particular card from a shuffled deck of 52 cards, for example the Ace of Spades Repeat each event: 1) 10 2) 100 3) 1000 4) 10,000 5) 100,000 times Within each set of repetitions, count how often each result occurs. Then compute the percentage of the total events were represented by each result. Ex: Coin: ---- Flips: 10 Heads: 40% Tails: 60% Die: ---- Rolls: 10 1: 10% 2: 0% 3: 20% 4: 30% 5: 30% 6: 10% Card: ---- Draws: 10 Card wanted: 0% Not card wanted: 100% ... Coin: ---- Flips: 100000 Heads: 49% Tails: 51% Die: ---- Rolls: 100000 1: 17% 2: 18% 3: 17% 4: 17% 5: 17% 6: 16% Card: ---- Draws: 100000 Card wanted: 2% Not card wanted: 98% 

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!