We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int sum (int count,...) {
int sum = 0;
va_list arr;
va_start(arr, count);
for(int x = 0; x<count; x++) {
sum += va_arg(arr, int);
}
return sum;
}
int min(int count,...) {
int min = 100000,a;
va_list arr;
va_start(arr, count);
for(int x = 0; x<count; x++) {
a = va_arg(arr, int);
if(min > a)
min = a;
}
return min;
}
int max(int count,...) {
int max = 0, a;
va_list arr;
va_start(arr, count);
for(int x = 0; x<count; x++) {
a = va_arg(arr, int);
if(max < a)
max = a;
}
return max;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Variadic functions in C
You are viewing a single comment's thread. Return to all comments →