Min and Max

Let's take a look at the functions C++ provides to check the minimum and maximum in a range.

You can determine the minimum, the maximum and the minimum and maximum pair of a range with the algorithms std::min_element, std::max_element and std::minmax_element. Each algorithm can be configured with a binary predicate.

Returns the minimum element of the range:

Get hands-on with 1200+ tech skills courses.