Min and Max Elements in C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<int> v = {6, 5, 9, 8, 50, 311, 22};
    // auto it = max_element(begin(v), end(v));
    auto it = min_element(begin(v), end(v));
    // cout << "Max Value is : "<<*it<<endl;
    cout << "Min Value is : " << *it << endl;

    return 0;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *