In: Computer Science
Create a C++ program that calculates an unbiased standard deviation of 5 input numbers.
Please Submit:
1. A flowchart of your program. (3 points)
2. Your C++ program with a heading comment, also appropriate spacing and indentation in the program body.
3. Copy of a screenshot after your program is executed. (Section 2 and3: 7 points)
/* ELEN 1301 Programming Assignment #8.
Name : Your name.
Student ID : Your student ID #.
Due date :
Purpose of the program : Creating a program that usus an array and calculate an unbiased standard deviation.
Section 1 : Receive a number and store it in an array. We assume there will be always 5 input numbers.
Section 2 : Repeat Section 1 five times.
Section 3 : Find the mean of the five numbers.
Section 4 : Subtract mean from each input that is stored in the array. Square it.
Section 5 : Repeat Section 4 for all the stored input, so that the summention is done.
Section 6 : Divide the sum by (N – 1), in this case it would be 4, and take a square root of the value to show the Standard Deviation.
Here is your C++ program to find out unbiased standard deviation of 5 input numbers.
Please hit that like or thumbs-up button, it really motivates me>3
stdDeviation..cpp
#include <iostream>
#include <cmath>
using namespace std;
float CalstdDeviation(float StoreArr[]);
int main()
{
int i;
float StoreArr[5]; // Array to store
// User input ,limited to 5 only
cout << "Enter five(5) elements: ";
for(i = 0; i < 5; ++i)
cin >> StoreArr[i];
cout << endl <<"Standard Deviation = " << CalstdDeviation(StoreArr)<<endl;
return 0;
}
// Function to find out standard deviation
float CalstdDeviation(float StoreArr[])
{
// variables
float sum = 0.0, mean, standardDeviation = 0.0;
int i;
for(i = 0; i < 5; ++i)
{
sum += StoreArr[i];
}
mean = sum/5;
for(i = 0; i < 5; ++i)
standardDeviation += pow(StoreArr[i] - mean, 2);
return sqrt(standardDeviation / 5);
}
Output: - Refer to screenshot
Flowchart :- Refer to below image
Again Please hit that like button>3 (I hope you will do that?)
Thank you!!