Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;
}

Explanation / Answer

Dear, Solved using function #include #include using namespace std; //Function prototype declaration double standard_Deviation(double x[],int n,int *sum,int *sumsqr,int *mean,int *var); const int MAXSIZE=100; //Main function void main() { //variable declaration double value[MAXSIZE]; double mean,sdeviation,sum,sumsqr,var; int i,num; cin>>num; //Inputting array values cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote