Answers for "built oin function to get maximumof vector"

C++
0

built oin function to get maximumof vector

//C++ STL program to find maximum or largest 
//element of a vector 
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    //vector
    vector<int> v1{ 10, 20, 30, 40, 50 };

    //printing elements
    cout << "vector elements..." << endl;
    for (int x : v1)
        cout << x << " ";
    cout << endl;

    //finding the maximum element
    int max = *max_element(v1.begin(), v1.end());

    cout << "maximum/largest element is: " << max << endl;

    return 0;
}
Posted by: Guest on February-20-2021

Code answers related to "built oin function to get maximumof vector"

Browse Popular Code Answers by Language