cplusplus.com > reference > cstdlib > max
max
<stdlib.h>
  cplusplus.com  
max ( a , b );

Return the greater of two parameters.
  Macro that returns the greater parameter. Defined as:

#define max(a,b) (((a)>(b))?(a):(b))

Parameters.

a,b
two values of the same type.

Return Value.
  The greater parameter, a or b.

Portability.
  Not defined in ANSI-C. Supported by some compilers. Usually not supported by modern C++ compilers.
  Some C++ compilers incorporate max as a template included in <algorithm>.

Example.

/* max example */
#include <stdio.h>
#include <stdlib.h>

int main ()
{
  int x=20, y=10, z;
  z= max (x,y);
  printf ("max is: %d\n",z);
  return 0;
}
Output:
max is: 20

See also.
  min


© The C++ Resources Network, 2000