1
CS31: Introduction to Computer Science I
Week 06 practice
Get familiar with functions and arrays Note: In this practice, you can assume all the parameters passed into these functions are valid (i.e., size is greater than 0, array is large enough)
Problem 1
Implement getAverage() function.
double getAverage(double a[], int n) { }
Have you tried the following test cases:
a = {1.0, 2.0, 3.0}, n = 3?
Problem 2
Implement getVariance() function. The definition of variance is:
double getVariance(double a[], int n) { }
Have you tried the following test cases:
a = {1.0, 2.0, 3.0}, n = 3?