Question 2
Back to Exercise
The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
int count;
double count;
int main(void) {
printf("%d\n", (int) count);
return 0;
}
- A Globals cannot be redeclared
- B The two declarations of count give it conflicting types Correct
- C count must be initialised
- D There is no bug
Correct Answer: Option B
Repeated declarations must agree on the type. Here one says int and the other double, so the compiler reports "redefinition with a different type". Use two different names.
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!