elibraryportal Logo

Constants and Literals in C

A constant is a value or variable that can not be changed by the program once they are defined.


  1. Integer constants
  2. Real or Floating point constants
  3. Octal & Hexadecimal constants
  4. Character constants
  5. String constants
  6. Backslash character constants
Constant type
Data type (Example)
Integer constants int (53, 762, -478 etc )
unsigned int (5000u, 1000U etc)
long int, long long int
(483,647 2,147,483,680)
Real or Floating point constants float (10.456789)
doule (600.123456789)
Octal constant int (Example: 013 /*starts with 0 */)
Hexadecimal constant int (Example: 0x90 /*starts with 0x*/)
character constants
char (Example: ‘A’, ‘B’, ‘C’)
string constants
char (Example: “ABCD”, “Hai”)

Rules for Constants

1) Integer Constants

  • In integer constant must have at least one digit.
  • It do not consist of decimal point.
  • It can either be positive or negative.
  • No commas or blanks are allowed within an integer constant.
  • An integer range is -32768 to 32767.

2) Real Constants

  • A real constant must have at least one digit
  • It contants decimal point.
  • It could be either positive or negative
  • No commas or blanks are allowed within a real constant.

3) Character And String Constants

  • A character constant constant single alphabet, a single digit or a single special symbol enclosed within single quotes.
  • The maximum length of a character constant is 1 character.
  • String constants are enclosed within double quotes.

4) Backslash Character Constants

  • In Backslash Character Constants contants some characters which have special meaning in C language.
  • List are below.
Backslash_character Meaning
\b Backspace
\f Form feed
\n New line
\r Carriage return
\t Horizontal tab
\” Double quote
\’ Single quote
\\ Backslash
\v Vertical tab
\a Alert or bell
\? Question mark
\N Octal constant (N is an octal constant)
\XN Hexadecimal constant (N – hex.dcml cnst)



 value of height : 100
value of number : 3.140000
value of letter : A
value of letter_sequence : ABC
value of backslash_char : ?    

Literals in C

Literals is a constant (fixed) values that cant not be change the tme of execution program.

Types of Literals

There are 4 types of literals that is.

  • Integer literal
  • Float literal
  • Character literal
  • String literal
Next TopicToken in C