A warehouse records parcel masses in kilograms. The following C++17 code runs with the required headers included and all operations succeeding.
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.
Unlock full course notes by signing up
Checking an unsuccessful registry search
An instrument registry runs this C++17 search with the required headers included. No operation changes the vector during or after the search.
Complete the safety rule using an expression that calls end() directly on codes. Write the expression without spaces: reading *pos is permitted only when pos is not equal to ________.
Counting distinct sensor IDs in place
A vector named ids holds the integer sensor IDs logged during a test run, with many repeats in no particular order. You want to remove the duplicates in place using standard algorithms and then report how many distinct sensors reported. Arrange the steps in the order they must run.
Two independent interface mistakes
A C++17 program records three network delays in milliseconds. The required headers are included. Assume the requested capacity is valid and the reservation succeeds.
Which statements correctly describe the library operations and their consequences? Select all that apply.
Hidden insertions in a stock map
In a small warehouse program, stock is a std::map from std::string keys to int values, and it starts empty. The program then runs these statements in order:
After all statements have run, give each quantity as a whole number: the value of stock.size(), the value of stock.count("gasket"), the value stored for the key bolt, and the final value of total.