What is the output of the following C program?
#include <stdarg.h>
#include <stdio.h>
int largest(int n, ...) {
va_list ap;
va_start(ap, n);
int best = va_arg(ap, int);
for (int i = 1; i < n; i++) {
int v = va_arg(ap, int);
if (v > best)
best = v;
}
va_end(ap);
return best;
}
int main(void) {
printf("%d %d\n", largest(4, 12, 99, -5, 40), largest(2, -8, -3));
return 0;
}
The first argument says how many values follow; the function reads exactly that many.