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++.

var

static

let

Next question

Find the option that is right for you!

All options are one-time payments.

$12.50

30 day premium pass

All the basics to get you started

  • Ad-free experience
  • View your previous attempt history
  • Mobile app access
  • In-depth explanations
  • 30 day premium pass access
$30.00 $87.50 usd

6 month DELUXE pass (most popular)

Everything with the 30 day premium pass FOR 6 MONTHS! & the ultimate digital PDF study guide (BONUS)

  • Everything included in the premium pass
  • $87.50 usd value for $30.00! You save $57.50!
  • + Access to the ultimate digital PDF study guide
  • + 6 months of premium pass access
  • + Priority support
$12.50 $18.99

Ultimate digital PDF study guide

For those that prefer a more traditional form of learning

  • Available for instant download
  • Available offline
  • Hundreds of practice multiple choice questions
  • Comprehensive content
  • Detailed explanations
Image Description
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy