return the greater of two numbers
#include <stdlib.h> #define max(a,b) (((a) > (b)) ? (a) : (b))
The max() macro will evaluate to be the greater of two values. It is implemented as follows:
#define max(a,b) (((a) > (b)) ? (a) : (b))
The max() macro will evaluate to the larger of the two values passed.
#include <stdio.h>
#include <stdlib.h>
void main()
{
int a;
/*
* The following line will set the variable "a"
* to 10, since 10 is greater than 1.
*/
a = max( 1, 10 );
printf( "The value is: %d\n", a );
}
WATCOM
All (except DOS/PM)