min
min ( a , b ); | stdlib.h |
cplusplus.com |
Return the smaller of two parameters.
Macro that returns the smaller parameter. Defined as:
#define min(a,b) (((a)<(b))?(a):(b))
Parameters.
Return Value.
The smaller 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 min as a template included in
<algorithm>.
Example.
/* min example */ #include <stdio.h> #include <stdlib.h> main () { int x=20, y=10, z; z= min (x,y); printf ("min is: %d\n",z); return 0; }Output:
See also.
max