This is just the outline of how I have began doing my standard deviation problem
ID: 3633604 • Letter: T
Question
This is just the outline of how I have began doing my standard deviation problem in c++. i have three outputs when i have this program. however when it does the "sum" or "sumsqr" or "n" the answers process the "-1" that is typed as a sentinel value. I want my program to ignore -1 and not include it with its calculation.for example, when the user inputs 1, 2 ,3, 4, -1 the sum should be 10 not 9 because I dont want the -1 to be included in that sum. -1 should just be the value that cuts a 100 value array to a 4 value array.
This is what i have so far:
#include <cstdlib>
#include <iostream>
#include <cmath>
int MAXSIZE = 100;
using namespace std;
int main()
{
int i, n;
float value[MAXSIZE], deviation, sum, sumsqr, mean, variance, sd;
sum = sumsqr = n = 0;
cout << "Input values: Input -1 to end" << endl;
for(i = 1; i < MAXSIZE; i++)
{
while(value[MAXSIZE] != -1)
{
cin >> value[MAXSIZE];
sum = sum + value[MAXSIZE] ;
sumsqr = sumsqr + pow(value[MAXSIZE],2);
n = n+i;
}
}cout << sum << endl;
cout << sumsqr << endl;
cout << n << endl;
system("PAUSE");
return EXIT_SUCCESS;
}