1*max_element (first_index, last_index);
2ex:- for an array arr of size n
3*max_element(arr, arr + n);
1int main()
2{
3 // Get the vector
4 vector<int> a = { 1, 45, 54, 71, 76, 12 };
5
6 // Print the vector
7 cout << "Vector: ";
8 for (int i = 0; i < a.size(); i++)
9 cout << a[i] << " ";
10 cout << endl;
11
12 // Find the max element
13 cout << "\nMax Element = "
14 << *max_element(a.begin(), a.end());
15 return 0;
16}
1int arr[] = {1,4,2,10};
2int n = 4; //size of array
3cout<<*max_element(arr,arr+n);
4
5// Output: 10