A very obvious problem is that you are not including the file that has the MIN
setting. But this will not solve the problem because this function (a macro actually) only accepts two arguments being passed and you are passing four. Then he would have to create a function of his own to deal with all these arguments. There is also a formula problem, so I put parentheses in the right place.
#include <stdio.h>
#include <stdarg.h>
float multiMin(int num, ...) {
va_list lista;
va_start(lista, num);
float min = va_arg(lista, double);
for (int i = 1; i < num; i++) {
float item = va_arg(lista, double);
if (item < min)
min = item;
}
va_end(lista);
return min;
}
int main(void) {
float a, b, c, d, res;
scanf("%f\n%f\n%f\n%f\n", &a, &b, &c, &d);
res = (a + b + c + d - multiMin(4, a, b, c, d)) / 3;
printf("%f", res);
return 0;
}
See running on ideone .
If you do not want to create a function just for this you can do the following:
int main(void) {
float a, b, c, d, res;
scanf("%f\n%f\n%f\n%f\n", &a, &b, &c, &d);
res = (a + b + c + d - fmin(a, fmin(b, fmin(c, d)))) / 3;
printf("%f", res);
return 0;
}
You must include the header <math.h>
.
Note that I preferred to use fmin()
than the MIN
macro. It will work better. I see no reason to use the macro in modern compilers.