Minimum and Maximum

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

We can determine the minimum and maximum elements of the range with std::min_element and std::max_element. If we want to find both the minimum and maximum pair of a range then we can use the algorithm, std::minmax_element. Each algorithm can be configured with a binary predicate.

std::min_element: Returns the minimum element of the range.

Get hands-on with 1400+ tech skills courses.