Question 10
Back to Exercise
What is the output of the following C program on a 64-bit system?
#include <stdio.h>
int count;
int count;
int count = 5;
int main(void) {
printf("%d\n", count);
return 0;
}
- A 5 Correct
- B 0
- C Compilation error: redefinition
- D Garbage
Correct Answer: Option A
A file-scope declaration without an initializer is a tentative definition and may be repeated. With an initializer it is the real definition, so count is 5. Two initialised definitions would be an error.
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!