max element in vector c++ 1

max element in vector c++

cout<<*max_element(a.begin(), a.end())<

Here is what the above code is Doing:
1. We are taking the input from the user and storing it in the variable n.
2. We are creating a vector of size n and taking the input from the user and storing it in the vector.
3. We are using the max_element function to find the maximum element in the vector.
4. We are printing the maximum element.

Similar Posts