max
max ( a , b ); | stdlib.h |
cplusplus.com |
Return the greater of two parameters.
Macro that returns the greater parameter. Defined as:
#define max(a,b) (((a)>(b))?(a):(b))
Parameters.
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>
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