Question 4
Back to Exercise
This program compiled (with warnings) as C17. Why does it fail to compile as C23?
#include <stdio.h>
int area();
int main(void) {
printf("%d\n", area(3, 4));
return 0;
}
int area(int w, int h) {
return w * h;
}
- A C23 removed the * operator for ints
- B In C23 int area(); means area takes no parameters, so area(3, 4) and the later definition conflict with it Correct
- C printf() needs %ld in C23
- D main() must come last in C23
Correct Answer: Option B
Before C23 empty parentheses meant "parameters unknown", so the call went unchecked. C23 treats them as (void). Write the full prototype: int area(int w, int h);.
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!