I need immediate help in writing a function program. I have to write a

program in functions and use array to store them. I am not familiar

with functions and i tried to create it but i fails to run, However, i

simply created this program in arrays and it runs good except i cant

figure out how to compute the standard deviation. The coding is below.

Any help will be appreciated.

1) The Program will prompt the user for six grades to be entered (one

at a time, read in each grade by the user , and them in an array of six

elements.

2) The average grade (again, on a 0.0 - 4.0 scale), by looping through

the array again;

3) The program will compute the standard deviation of the six

individual grades from the average according to following formula:

n-1

E (x[i] - avg)2

I=0___________________

n-1

where n is the number of values that were averaged (6 in this case),

x[i] is a particular value, and avd of all n values. I.e for each of

the n values, you take the difference between that value and the

average, square that difference, and sum all n squares. Then divid that

sum by n-1 and take the square root of that quotient. This gives you

the standard deviation.

#include <iostream>

using namespace std;

int main()

{

const int SIZE = 6;

double score[SIZE];

int i =0;

double sum = 0;

string grade;

for ( i = 0; i < SIZE; i++)

{

cout << "Input a Score " << i+1 << ":" ;

cin >> score[i];

while (score[i] > 4 || score[i] < 0)

{

cout <<" Invalid grade - please re-enter a grade"

<< " between 0 and 4.0 inclusive : ";

cin >> score[i];

}

sum = sum + score[i];

}

double average = sum / 6 ;

if (average <= 4.0 && average > 3.2)

{

grade = "A";

}

if (average <= 3.2 && average > 2.4)

{

grade = "B";

}

if (average <= 2.4 && average > 1.6)

{

grade = "C";

}

if (average <= 1.6 && average > 0.8)

{

grade = "D";

}

if (average <= 0.8 && average > 0)

{

grade = "F";

}

// Output the result:

cout << "The average is " << average << "." << endl;

cout << "The final letter grade is " << grade << endl;

return 0;

} // function main