Format
#include <stdlib.h> type max(type a, type b);
Language Level: Extension
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.
Return Value
max returns the larger of the two values.
Example
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 **********************************************************/ }
![]()
min -- Return Lesser of Two
Values
<stdlib.h>