Algorithms min and max determine the minimum and the maximum of two elements, respectively. - C++ STL Algorithm

C++ examples for STL Algorithm:min

Introduction

The following code demonstrates min and max for int and char values.

Demo Code



#include <iostream> 
#include <algorithm> 
using namespace std; 

int main() //from  w  w  w  . j ava2s . c  om
{ 
    cout << "The minimum of 12 and 7 is: " << min( 12, 7 ); 
    cout << "\nThe maximum of 12 and 7 is: " << max( 12, 7 ); 
    cout << "\nThe minimum of 'G' and 'Z' is: " << min( 'G', 'Z' ); 
    cout << "\nThe maximum of 'G' and 'Z' is: " << max( 'G', 'Z' ); 
    cout << endl; 
}

Result


Related Tutorials