Question: Write a program that can be used to compute the sum, sum of squares, mean or average and standard deviation of a few numbers that
- Write a program that can be used to compute the sum, sum of squares, mean or average and standard deviation of a few numbers that are entered by the user.
You need to use a while loop with loop count starting from 1 to N where N is number of data entered.
Initialize sum and sum of squares to 0, and then within the loop, add the new number to sum and square of the new number to sum of square.
To compute the sum, you can use: sum = sum + number;
For sumOfSquare, use, sumOfSquare = sumOfSquare + pow(number, 2);
After exiting the loop, find the average and standard deviation from the following:
average = sum/N
standardDeviation = sumOfSquare- sum2n(n-1)
Display the sum, sumOfSquare, average and standard deviation using a precision of 2 (i.e displaying 2 digits after the decimal).
Declare all the variables, sum, sumOfSquare, standardDeviation as floating-point variables.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
