Question 7
Back to Exercise
The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
int main(void) {
extern int limit = 5;
printf("%d\n", limit);
return 0;
}
- A extern cannot be used with int
- B An extern declaration at block scope only refers to an object defined elsewhere; it cannot also define it with an initializer Correct
- C limit must be static
- D There is no bug
Correct Answer: Option B
Inside a function, extern int limit; refers to a file-scope definition. Defining it needs a file-scope declaration such as int limit = 5; outside main().
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!