< C Tutorial

C constant and literals

← Previous Next →


Constant 

  • Constant refers to variables having fixed values that the program can't change during its execution.

Literals

  • Fixed value assigned to constant are called literals.

Constant definition in C

const keyword is used to define a constant variable.

Example :

const int employeeId = 121 ;

const float salary = 20145.50 ;

Types of literals:

  • Integer literals

    10 // number
    0x20 // hexadecimal
    0123 // octal
  • Float literals

    10.23
    1003E-2
  • Character literals

    'a'
    'A'
  • String literals

    "Hello"
    "George"
← Previous Next →