Literals In C Programming Language

Literals Definition

Literals are a sequence of characters that represent constant values.

These constant values occupy memory but do not have any reference like variables.

Constants can be defined as any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are varius different constants as well.

Types of Literals

There are basically four types of literals in C programming.

  • Integer Literals
  • Float-point Literals
  • Character Literals
  • String Literals

1) Integer Literals

An Integer literals are the primary literals used in C programming.

During the declaration of an integer constant, a prefix is used along with the value to specify the base or radix.

An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. It can be either uppercase or lowercase format and it also can be in any order.

constant can be specified in three ways:


Decimal(base 10) literals appear as ordinary numbers with no special notation.


An integer literal for the decimal number 12 is represented in C as 12 in decimal.


Hexadecimal numbers (base 16) appear with a leading 0x or 0X.


Octal (base 8) numbers appear with a leading in front of the digits.


an integer literal for the decimal number 12 is represented in C as 014 in octal.

 12     /* decimal */
 014    /* octal */
 0x4c  /* hexadecimal */
 45    /* int */
 20u   /* unsigned int */
 20l   /* long */
 20ul  /* unsigned long */

2) Floating point literals

Floating-point literals represent decimal numbers with fractional parts, such as 3.142. They can be expressed in either standard or scientific notaion, meaning that the number 563.84 also can be expressed as 5.6384e2.


 3.14159    /* Legal */
 314159E-5L /* Legal */
 510E /* incomplete exponent */
 210f /* no decimal or exponent */
 .e55 /* missing integer or fraction */

3) Character literals

Character literals represent a single Unicode character and appear within a pair of single quotation marks.


 'A' (or) '5' (or) 'p' etc.

4) String Literals

String literals represent multiple characters and apear within a pair of double quotation marks. String literals are implemented in C by the using double quotes("").


 "hello, world"

 "hello, \


 "hello, " "wo" "rld"