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

need help filling inthe blanks because that part of my code I keep failing at. b

ID: 3633644 • Letter: N

Question

need help filling inthe blanks because that part of my code I keep failing at. by the way, that the way the code has to be set up: thks

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++)
{

//FILL IN
}

//compute mean
for(i =1; i <=n; i ++)
(
//FILL IN
}

//compute variance and sd

cout << n << " " << "N" << endl;
cout << mean << " " << " is the Mean" << endl;
cout << sd << " " << "is the SD" << endl;

system("PAUSE");
return EXIT_SUCESS;
}

Explanation / Answer

/*
You are not making any use of the array! All the values are being read into an element just past the last element (zero based array, indices are 0 to MAXSIZE-1). And why do you have a while-loop nested inside a for-loop???

Here are two versions. The first doesn't make use of the array, and reads all data into a temporary variable. The second makes use of the array.

The comma operator in the while loop evaluates both expressions and returns the value of the last one.
*/

#include

using namespace std;

int main()
{
// VERSION 1: No array
float sum = 0;
float sumsqr = 0;
float currentInput;
int n = 0;
cout << "Input values: Input -1 to end" << endl;

while ( (cin >> currentInput), currentInput != -1)
{
sum += currentInput;
sumsqr += currentInput * currentInput;
n++;
}

cout << sum << endl;
cout << sumsqr << endl;
cout << n << endl;

//VERSION 2: Yes array
float value[100];
sum = 0;
sumsqr = 0;
n = 0;
cout << "Input values: Input -1 to end" << endl;

while ( (cin >> value[n]), value[n] != -1)
{
sum += value[n];
sumsqr += value[n] * value[n];
n++;
}

cout << sum << endl;
cout << sumsqr << endl;
cout << n << endl;

return 0;
}