Question 2
Back to Exercise
The program below has a bug. Which statement correctly describes it?
#include <stdarg.h>
#include <stdio.h>
int sum(..., int count) {
return count;
}
int main(void) {
printf("%d\n", sum(1, 2, 3));
return 0;
}
- A count must be unsigned
- B sum must use va_list
- C There is no bug
- D The ellipsis must be the last thing in the parameter list; named parameters come before it Correct
Correct Answer: Option D
Write int sum(int count, ...) and call it as sum(3, 1, 2, 3).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!