Question: Today's program will ask you to calculate the standard deviation of 10 random numbers. To do this you will use the following formula: StdDev=i=1i=N(xixavg)2N Your
Today's program will ask you to calculate the standard deviation of 10 random numbers. To do this you will use the following formula:
StdDev=i=1i=N(xixavg)2N
Your program follow the following steps:
- Create an array of datatypedoublewith 10 elements.
- In one loop, generate random numbers between 20 and 80 (using a random number generator, seeded with time) and store into each element of the array. Also, in this loop, print each of the randomly generated numbers to the screen, all on a single line of output.
- In a separate loop, sum the values up so that you can calculate the mean(average) of the generated values. After this loop, calculate the average.
- Using a third loop, calculate the sum of the squares of the difference of each element and the average you calculated above. That is, calculate this:
- i=1i=N(xi-xavg)2
wherexiis one element of the array,xavgis the mean(average) value of the array,Nis equal to the number of elements(in this case 10).
- Once the loop is over, divide the sum byN, which in this case is 10 and take the square root of that value.
- Once completed, print the mean(average)(3 decimal places), and the Standard Deviation to 4 decimal places.
Sample output:
53 43 64 71 45 73 72 68 73 26 The mean value is: 58.800 The standard deviation of the numbers was: 15.4519
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
