Which of the following statements creates a named constant called driverAge whose value is 16?

const driverAge = 16;
const short driverAge = 16;
driverAge =16;
driverAge const =16; E. namedconst driverAge =16;

The correct answer is: A. const driverAge = 16;

A named constant is a variable that cannot be changed after it has been initialized. To create a named constant, you use the const keyword followed by the variable name and its value. In this case, the variable name is driverAge and its value is 16.

The other options are incorrect for the following reasons:

  • Option B: The short keyword is used to declare a variable of type short. In this case, the variable type is not specified, so the variable is of type int.
  • Option C: The assignment operator (=) is used to assign a value to a variable. In this case, the variable is not declared, so the statement is not valid.
  • Option D: The keyword const is used to declare a named constant. In this case, the variable name is not followed by an equal sign, so the statement is not valid.
  • Option E: The keyword namedconst is not a valid keyword in C++.
Exit mobile version