A constant is a value which will not change during the execution of a program.
Constants are those values in programming language which cannot be modified once they are defined. They are fixed values in a program.
Types of C++ Constants:-
Integer Constant:- An integer is a whole number without any decimal point or a fraction part. No extra characters are allowed other than ‘+’ and ‘-‘ sign.
The integer Constants are divided into three types:-
Decimal(10, 140, -140 etc.)
Octal(010, 0140, 0440 etc.)
Hexadecimal(0x8A, 0xAB, 0xA123)
Floating-Point Constants : The floating point constants are base 10 numbers with fraction part such as 10.5. All negative numbers should have a prefix ‘-‘. A positive number can have as optional ‘+’ sign. No other extra characters are allowed.
Character Literals : A symbol enclosed within a pair of single quotes(‘apostrophe denoted by the symbol’) is called a character constant.
String Literal : A sequence of characters(i.e., one or more characters)enclosed within a pair of double quotes is called a string constant.