standard deviation assistance

This is my code so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

int main()
{
float numbers[15];
float sum, lowest, highest;
float min, max, range, stDev, mean, median;
int indexOfMin;
float above = 0, below = 0;


sum = 0;
for(int testNum = 0; testNum < 15; testNum++)
{
cout << "Please enter your 15 numbers: ";
cin >> numbers[testNum];
sum = sum + numbers[testNum];
}
mean = sum/15;
for(int testNum = 0; testNum < 15; testNum++)
{
if(numbers[testNum] < mean)
{
below++;
}
else if(numbers[testNum] > mean)
{
above++;
}
}
lowest = numbers[0];

for(int testNum = 0; testNum < 15; testNum++)
{
if(numbers[testNum] < lowest)
lowest = numbers[testNum];
}

highest = numbers[0];
for(int testNum = 0; testNum < 15; testNum++)
{
if(numbers[testNum] > highest)
highest = numbers[testNum];
}

for(int outer = 0; outer < 14; outer++)
{
min = numbers[ outer]; //set the proposed min to the first element in the first part of the array that is not yet sorted
indexOfMin = outer; //save the index number of this min value
for(int inner = outer+1; inner < 7; inner++) //now loop thru the rest of the array to find the smallest element
{
if(numbers[inner] < min ) //find the new min out of the rest of the elements besides the starting element
{
min = numbers[inner];
indexOfMin = inner;
}
}
numbers[indexOfMin] = numbers[outer]; //swap the new min value with the first element in this iteration
numbers[outer] = min;

}


cout << "Your mean is: " << sum/15 << endl;
cout << "Your range is: " << highest-lowest << endl;
cout << "Your median is: " << min << endl;
cout << "Your standard deviation is: " << stDev << endl;
cout << "Your maximum is: " << highest << endl;
cout << "Your minimum is: " << lowest << endl;


return 0;
}


Im unsure of how to code in the standard deviation of the input (the 15 values the user will input). Could someone help show me or explain to me how I would add that into my code? I'm a visual person, so a big long paragraph will lose me LOL
Last edited on
Topic archived. No new replies allowed.