Question 3
Back to Exercise
Is const double pi = acos(-1.0); valid inside a function?
- A No, const needs a literal
- B Yes – a const local may be initialised with any expression and is read-only afterwards Correct
- C Only with static
- D Only in C23
Correct Answer: Option B
const means "not modified after initialisation", not "known at compile time". Only objects with static storage (globals, static locals) need constant initializers.
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!