Constants in C Language
Constants are like regular variable, except that their value can not be modified during the entire execution of the program once they are defined.
Constants Types
Constants are categorized into two basic types : 1) Primary Constants, & 2) Secondary Constants. Each types has its subtypes/categories, which are shown below :
- Primary Constants
- Integer Constant
- Decimal Integer - Example: 12, -597, 0, 56789
- Octal Integer - Example: 045, 0213 → starts with 0
- Hexadecimal Integer - Example: 0x2b, 0x6d, 0xab → starts with 0x
- Real or Floating Points Constant - Example: 75.25, 3.27359, 427359E-5L → e or E represents signed exponent
- Character Constant
- Single Character Constants - Example: 'A', 'b', 'W', 'x', '5', ';'
- String Constants - Example: "Hi!", "Hello World", 2021", "5+4"
- Backslash Character Constants - Example: \t for tab, \n for new line
- Integer Constant
- Secondary Constants
- Array
- Pointer
- Structure
- Union
- Enum
Backslash Character Constants
• Given below is the list of special characters and their usages.
Backslash character | Meaning |
\a | Alert or Beep sound |
\b | Backspace |
\f | Form feed |
\n | New line |
\r | Carriage return |
\t | Horizontal tab |
\v | Vertical tab |
\" | Double quote |
\' | Single quote |
\\ | Backslash |
\? | Question mark |
\N | Octal constant |
\XN | Hexadecimal constant |
\0 | Null |
ADVERTISEMENT