Constants
- Constants are called as Literals.
- They are like variables, except that their value never changes during execution once defined.
- The 'const' keyword is used to define constraints in C++.
- It is possible to put const either before or after the data type.
Syntax:
const datatype constant_name;
Example:
const int a = 10;
Example:
int const a = 10;
Literals
Following are the types of Literals:| Literals | Description |
|---|---|
| Integer Literal | It can be a decimal, octal or hexadecimal constant. |
| Floating-point Literal | It has an integral part, a decimal point, a fractional part and an exponent part. |
| Boolean Literal | It has two boolean literals: True and False. |
| Character Literal | These literals are enclosed in single quote. |
| String Literal | These literals are enclosed in double quotes. |
Escape Codes
- Escape codes are used to present the characters which are difficult to express in the source code.
- All escape codes are start with a blackslash (\).
| Escape Codes | Meaning |
|---|---|
| \n | Newline |
| \r | Carriage return |
| \t | Tab |
| \v | Vertical tab |
| \b | Backspace |
| \f | Form feed |
| \a | Alert |
| \' | Single quote |
| \" | Double quote |
| \? | Question mark |
| \\ | Backslash |


