Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (17 sloc) 321 Bytes
#include <stdarg.h>
#include <stdio.h>
double average(int count, ...) {
va_list ap;
int j;
double sum = 0;
va_start(ap, count);
for(j = 0; j < count; j++) {
sum += va_arg(ap, int);
}
va_end(ap);
return sum/count;
}
int main(int argc, char const *argv[]){
printf("%f\n", average(3, 1, 2, 3));
return 0;
}
You can’t perform that action at this time.