Constants in C
A constant is an entity that doesn't change during the executin of a program. Followings are the different types of constants: Example: const int a=20;
- Octal constants are written with a leading zero 015
- Hexadecimal constants are written with a leading 0x 0x15
- Long constants are written with a trailing L. 15L
- Real Cosntant:
- It must have at least one digit.
- It must have a decimal point which may be positive or negative.
- Use of blank space and comma is not allowed between real constants.
- Example: +194.143, -416.41
- Integer Constant:
- It must have at least one digit.
- It should not contain a decimal place
- It can be positive or negative.
- Use of blank space and comma is not allowed between real constants.
- Example: 1990, 194, -394
- Character Constant:
- It is a single alphabet or a digit or a special symbol enclosed in a single quote.
- Maximum length of a character constant is 1.
- Example: "T", '9', '$'
- String Constant:
- It is a collection of characters enclosed in a double quotes.
- It may contain letters, digits, special characters and blank spaces.
- Example: "Islmaiah College, Vaniyambadi."