Question: Write a C++ program that determines the probability of tossing a coin 10 times and getting exactly 0, 1, 2, 3, etc. heads. This is

Write a C++ program that determines the probability of tossing a coin 10 times and getting exactly 0, 1, 2, 3, etc. heads. This is the binomial probability distribution. Store the probability in an array. Use a for loop. The for loop will go from 0 to 10 inclusive. Use r as the number of successes. So r will go from 0 to 10. The probability of a success is .5, and also the probability of a failure is .5. Print out in table form, column 1=r; goes 0 to 10, and then column 2; the probability of r. Use 4 decimal places for the probability. You know if you get the correct answers because The sum of all the probabilities is 1.0, and all probabilities are in the range of 0 to 1 inclusive. I would make my variables just like the ones in the formula. So instead of r to control the for loop, use x, and for sample size use N=10, and your probability of a success is .5, and your probability of a failure is also .5. When you calculate the probability of x successes store that probability in an array so that you can print in another loop.

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!