Which of the following numerical value(s) is(are) invalid constant(s)?

0.7
9.3el2
27,512
12345678 E. None of the above

The correct answer is: B. 9.3el2

A constant is a value that does not change during the execution of a program. It can be a number, a string, or a character.

A valid constant is a constant that follows the rules of the programming language. In C++, a valid constant must be:

  • A number: A number can be an integer, a floating-point number, or a complex number.
  • A string: A string is a sequence of characters enclosed in double quotes.
  • A character: A character is a single letter, digit, or symbol.

The constant 9.3el2 is not a valid constant because it does not follow the rules of C++. The exponent must be a whole number, but 2 is not a whole number.

The other options are all valid constants.

  • 0.7 is a valid number.
  • 27,512 is a valid integer.
  • 12345678 is a valid integer.
Exit mobile version