You are viewing a single comment's thread. Return to all comments →
int sum (int count,...) { va_list ptr; int sum=0; va_start(ptr, count); for(int i=0;i<count;i++) { sum+=va_arg(ptr, int); } va_end(ptr); return sum; } int min(int count,...) { va_list ptr; va_start(ptr, count); int max=va_arg(ptr, int); for(int i=0;i<count;i++) { int temp = va_arg(ptr, int); max = temp<max ? temp : max; } return max; } int max(int count,...) { va_list ptr; va_start(ptr, count); int min=va_arg(ptr, int); for(int i=0;i<count;i++) { int temp = va_arg(ptr, int); min = temp>min ? temp : min; } return min; }
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 →