    01: #include <iostream>
    02: #include <vector>
    03:
    04: using namespace std;
    05:
    06: /**
    07:    Computes the average of a vector of floating-point values.
    08:    @param v a vector of floating-point values
    09:    @return the average of the values in v
    10: */
    11: double average(vector<double> v)
    12: {
    13:    if (v.size() == 0) return 0;
    14:    double sum = 0;
    15:    for (int i = 0; i < v.size(); i++)
    16:       sum = sum + v[i];
    17:    return sum / v.size();
    18: }
    19:
    20: int main()
    21: {
    22:    vector<double> salaries(5);
    23:    salaries[0] = 35000.0;
    24:    salaries[1] = 63000.0;
    25:    salaries[2] = 48000.0;
    26:    salaries[3] = 78000.0;
    27:    salaries[4] = 51500.0;
    28:
    29:    double avgsal = average(salaries);
    30:    cout << "The average salary is " << avgsal << "\n";
    31:    return 0;
    32: }