KAMSC Sophomore Computer Science Semester 1 Practice Test 2026 – The All-in-One Resource for Exam Success!

Session length

1 / 20

Which keyword is used to define a constant variable in C++?

const

In C++, the keyword used to define a constant variable is "const." When you declare a variable with this keyword, you are indicating that its value cannot be modified after it has been initialized. This is useful for defining constants that are meant to remain unchanged throughout the program, enhancing readability and maintainability. For example, when you write `const int MAX_VALUE = 100;`, the program prevents any attempt to change `MAX_VALUE` later on, which helps in avoiding unintended behavior or bugs in the code.

The other keywords listed do not serve the purpose of defining constant variables. "var" is not a keyword in C++, while "static" specifies a storage duration for variables and affects their linkage and lifetime rather than their mutability. "let" is a keyword used in languages like JavaScript but does not apply to C++. Therefore, "const" is the only appropriate choice for defining constant variables in C++.

Get further explanation with Examzify DeepDiveBeta

var

static

let

Next Question
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy