Here is the source code of the C++ program which prints maximum of two values using max algorithm. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
* C++ Program to print maximum of two values using max() algorithm
int a, b;
std::cout << "Enter a = ";
std::cin >> a;
std::cout << "\nEnter b = ";
std::cin >> b;
std::cout << "\nMaximum of a and b is "
<< std::max(a, b) << std::endl;
$ a.out Enter a = 10 Enter b = 20 Maximum of a and b is 20 $ a.out Enter a =-40 Enter b = 20 Minimum of a and b is 20
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.