1)- Write a program that includes two functions named calcavg() and variance().
ID: 3609683 • Letter: 1
Question
1)- Write a program that includes two functions namedcalcavg() and variance().The calcavg() function should calculate and returnthe average of the values stored in an array namedtestvals. the array should be declared in main()and include the values 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79,75, 82, 73. The variance() function shouldcalculate and return the variance of the data.The variance isobtained by substracting the average from each value intestvals, squaring the values obtained, addingthem, and dividing by the number of elements intestvals. The values returned fromcalcavg() and variance should be displayed usingcout statements in main().Explanation / Answer
PLEASE RATE //header files #include #include using namespace std; //prototypes int calcAvg(int values[], int num); int variance(int values[], int num, int average); int main() { //initialize variables int avg, vari; int SIZE=14; int testVals[SIZE]={89, 95, 72, 83,99, 54, 86, 75, 92, 73, 79, 75, 82, 73}; //call calcAvg function avg= calcAvg(testVals, num) //call variance function vari=variance(testVals, avg, num); //cout average and variance coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.