C++ Tutorials

C++ Tutorials

  • A identifier which does not change its value during execution of a program is known as a constant or a literal.

Any attempt to change the value of a constant will result in an error message.

A keyword const is added to the declaration of an identifier to make that identifier constant.

Syntax :

  const datatype variable = value;

Example :


  const float PI = 3.1415;
  const char ch = 'A';
  const int rate  = 40;