Also in C++11 you can do this, using the initialiser list version of the std::max() function:
1 2 3 4 5 6 7 8
#include <algorithm> // std::max
int a = 5;
int b = 12;
int c = 17;
int d = 13;
int e = 9;
cout << "max({a, b, c, d, e}) == " << std::max({a, b, c, d, e}) << '\n';
Also in C++11 you can do this, using the initialiser list version of the std::max() function:
You could to it in C++03 too, using the binary version of std::max() multiple times.
1 2 3 4 5 6 7 8
#include <algorithm> // std::max
int a = 5;
int b = 12;
int c = 17;
int d = 13;
int e = 9;
cout << "max(a, b, c, d, e) == " << std::max(a, std::max(b, std::max(c, std::max(d, e)))) << '\n';