This is my code so far:
#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?