Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdarg.h>
- int add(int n, ...)
- {
- int sum = 0;
- va_list vlist;
- va_start(vlist, n);
- for(int i = 0; i < n; i++)
- {
- sum += va_arg(vlist, int);
- }
- va_end(vlist);
- return sum;
- }
- int main()
- {
- int sum;
- sum = add(4, 3, 9, 3, 4);
- printf("The sum of those numbers is %d\n", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement