Question 1
Back to Exercise
The program below does not compile. Which statement correctly describes the problem?
#include <iostream>
int main() {
auto total;
total = 42;
std::cout << total << '\n';
return 0;
}
- A 42 is too large
- B auto deduces the type from the initialiser, so a declaration without one has no type; write auto total = 42; or int total; Correct
- C auto needs a header
- D total must be const
Correct Answer: Option B
auto is compile-time deduction, not a dynamic type.
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!