# C Constants

Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.

### Integer(numeric) Constants

An integer constant refers to a sequence of digits. There are three types of integers, namely, a decimal integer, octal integer, hexadecimal integer.

1. 11
2. 31
3. -71
4. -24

An octal integar consists of a set of the digit,0 through 7, with a leading 0.For example:-

1. 001
2. 012
3. 000
4. 065

A sequence of digits preceded by 0x or 0X is considered as hexadecimal integar.They are alos included A to F where A represents the number 10 through 15.For example:-

1. 0x2
2. 0x6A or 0X6a

### The rule for Integer Constants

1. An integer constant must have one digit
2. It must not have a decimal point
3. It can be either positive or negative
4. If no sign precedes an integer constant, it is assumed to be Positive
5. No commas or blanks are allowed within an integer constant
6. Range follow:- -2147483648 to +2147483647

Integer numbers are inadequate to represent quantities that vary continuously, such as distance, temp, price, etc…These quantities are represented by number by a number containing fractional parts like 19.087.For example:-

1. 80.67
2. 0.878e5

* It may be written in exponential notation.

### Character Constants

A Character constant contains a single character enclosed within a pair of single quote marks. For example:-

Note that the character constant ‘7’ and ‘1’ is not the same as 5 and 1.

### The rule for Character Constants

1. A constant is a single alphabet, a single digit, or a special symbol
2. It enclosed in single quotes

### String Constant

A string constant is a sequence of characters enclosed in double-quotes. The character may be letters, numbers, special characters. For examples:-

## Backslash character constants

C support some special constant that is used in output functions. For example, the symbol ‘\t’ stands for horizontal tab while ‘\v’ stands for vertical tab. A list of such backslash is given:-

### Defining Constants

1. Using const keyword.
2. Using #define preprocessor.

### Using const keyword

You can use const word to declare constants.For example

const data_type var_name = value;

C Code Example

Using #define preprocessor

synatx

1. #define identifier value

C Code Example