Syntax
#include <stdlib.h> type max(type a, type b);Description
max compares two values and determines the larger of the two. The data type can be any arithmetic data type, signed or unsigned. Both arguments must have the same type for each call to max.
Note: Because max is a macro, if the evaluation of the arguments contains side effects (post-increment operators, for example), the results of both the side effects and the macro will be undefined.
max returns the larger of the two values.
This example prints the larger of the two values, a and b.
#include <stdlib.h> #include <stdio.h> int main(void) { int a = 10; int b = 21; printf("The larger of %d and %d is %d\n", a, b, max(a, b)); return 0; /**************************************************************************** The output should be: The larger of 10 and 21 is 21 ****************************************************************************/ }Related Information