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
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