Ace Your C++ Skills 2025 – Rock the ‘Thinking in C++’ Challenge!

Question: 1 / 565

If a variable is initialized at runtime and is known not to change, what practice is preferred?

Mark it volatile

Mark it const

Constants, marked by the "const" keyword, are variables whose values cannot be changed after they are initialized. This is the preferred practice for variables that are known not to change at runtime.

Option A, marking the variable "volatile", is incorrect because "volatile" indicates that the value of the variable may change unexpectedly and frequently.

Option C, marking the variable "static", is incorrect because "static" variables can still be modified within the scope of their declaration.

Option D, marking the variable "extern", is incorrect because "extern" variables are used for referring to variables declared in other source files. It does not match the criteria of a known, unchanging variable initialized at runtime.

Get further explanation with Examzify DeepDiveBeta

Mark it static

Mark it extern

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy