C++ Constants C++ constants is a quantity that cannot be changed during program execution. Following are two types of constants in C++: Literal constant Symbolic constant 1) Literal constant A…
Constant In C++. C++ constants is a quantity that cannot be changed during program execution. Following are two types of constants in C++: 1) Literal-constant 2) Symbolic constant.
A literal-constant is a value that is typed directly in a program. It appears in the program wherever it is needed.
Different types of literal-constants are as follows. An integer constant, Floating point constant, Character constant, and String constant.
A symbol is a name given to values that cannot be changed. A constant must be initialized. After a constant is initialized, its value cannot be changed. Symbolic constants are used to represent a value that is frequently used in the program.
A symbolic-constant PI can be used to indicate that value of Pi which is 3.141593. I can be written in the program wherever its value is required.
Symbolic-constants can be used declared in two ways: 1) const-Qualifier 2) define-directive 3) const-Qualifier.