home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
Search
showing results for
1//C++ STL program to find maximum or largest 
2//element of a vector 
3#include <iostream>
4#include <algorithm>
5#include <vector>
6using namespace std;
7
8int main()
9{
10    //vector
11    vector<int> v1{ 10, 20, 30, 40, 50 };
12
13    //printing elements
14    cout << "vector elements..." << endl;
15    for (int x : v1)
16        cout << x << " ";
17    cout << endl;
18
19    //finding the maximum element
20    int max = *max_element(v1.begin(), v1.end());
21
22    cout << "maximum/largest element is: " << max << endl;
23
24    return 0;
25}
26
upvote
downvote
source
similar questions
queries leading to this page