Question 5
Back to Exercise
The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
int main(void) {
const int max;
max = 10;
printf("%d\n", max);
return 0;
}
- A const must be global
- B A const object can only get its value from its initializer; assigning to it later is an error Correct
- C max must be unsigned
- D There is no bug
Correct Answer: Option B
Write const int max = 10;. A local const without an initializer is legal but useless – it holds garbage that can never be fixed.
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!