This file has both syntactic and semantic errors. I managed to fix a few, but im still having issues... The program should compute an average grade of 76 and a standard deviation of 13. I'm new to programming, and any assistance would be much appreciated!
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
float find_avg(int [], int); // function prototype
float std_dev(int [], int, float); // function prototype
int main()
{
const int NUMELS = 10;
int values[NUMELS] = {98, 82, 67, 54, 78, 83, 95, 76, 68, 63};
float average, stddev;
float findAvg(int nums[], int numel)
average = findAvg(values, NUMELS); // call the function
stddev = stdDev(values, NUMELS, average); // call the function
cout << "The average of the numbers is "
<< setw(5) << setiosflags(ios::showpoint)
<< setprecision(2) << average << endl;
cout << "The standard deviation of the numbers is "
<< setw(5) << setiosflags(ios::showpoint)
<< setprecision(2) << stddev << endl;
return 0;
}
float findAvg(int nums[], int numel)
{
int i;
float sumnums = 0.0;
for (i = 0; i < numel; i++) // calculate the sum of the grades
sumnums = sumnums + nums[i];
return (sumnums / numel); // calculate and return the average
}
float stdDev(int nums[], int numel, float av)
{
int i;
float sumdevs = 0.0;
for (i = 0; i < numel; i++)
sumdevs = sumdevs + pow((nums[i] - av),2);
return(sqrt(sumdevs/numel));
}