meow_god
20
Q:

max in c++

cout << " max element is: " << *max_element(array , array + n) << endl;
3
// C++ program to demonstrate the use of std::max 
// C++ program to demonstrate the use of std::max 
#include<iostream> 
#include<algorithm> 
using namespace std; 
int main() 
{ 
    // Comparing ASCII values of a and b 
    cout << std::max('a','b') << "\n"; 
  
    // Returns the first one if both the numbers 
    // are same 
    cout << std::max(7,7); 
  
return 0; 
}  
3
int main() 
{ 
    // Get the vector 
    vector<int> a = { 1, 45, 54, 71, 76, 12 }; 
  
    // Print the vector 
    cout << "Vector: "; 
    for (int i = 0; i < a.size(); i++) 
        cout << a[i] << " "; 
    cout << endl; 
  
    // Find the max element 
    cout << "\nMax Element = "
         << *max_element(a.begin(), a.end()); 
    return 0; 
} 
1
2147483647
  unsigned long long int = 18 446 744 073 709 551 615
3
// C++ program to demonstrate the use of std::max_element 
#include <iostream> 
#include <algorithm> 
using namespace std; 
int main() 
{ 
    int v[] = { 'a', 'c', 'k', 'd', 'e', 'f', 'h' }; 
  
    // Finding the maximum value between the first and the 
    // fourth element 
  
    int* i1; 
    i1 = std::max_element(v, v + 4); 
  
    cout << char(*i1) << "\n"; 
    return 0; 
} 
0

New to Communities?

Join the community