Interpreting a parcel-mass report

A warehouse records parcel masses in kilograms. The following C++17 code runs with the required headers included and all operations succeeding.


C++
std::vector masses{9, 4, 9, 6, 13};
masses.push_back(8);
std::sort(masses.begin(), masses.end());
auto total = std::accumulate(
    masses.begin(), masses.end(), 0.0);
double mean = total / masses.size();
auto matches = std::count(
    masses.begin(), masses.end(), 9);
int selected = masses.at(2);


Find total in kg to the nearest whole kilogram, mean in kg to two decimal places, matches as an exact integer count, and selected in kg to the nearest whole kilogram.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More C++ Standard Library Questions: