C Programming language

C Programming Language: Constants
Previous Home Next

The value of constant never be change. We can declare const before or after type. For ex. int const num=56; Or const int num=78; both are correct.

Types Of Constants

These constants are further categorized as

  • Primary Constants (Integer Constants, Real Constants, Character Constants)
  • Secondary Constants (Array, Pointer, Structure, Enum ect)
Rules for constructing Integer Constant
  • It must not have a decimal point
  • It can be either positive or negative
  • No commas and blanks are allowed within an integer constant
  • The allowable range for integer constant is -32768 to 32767

Examples of Integer Constant

426, +786, -7605 etc.


Rules for creating Real Constants

Real Constants are often called Floating Point Constants. The Real Constant could be written in two forms Fractional Form and Exponential form.

  • A real constant must have at least one digit
  • It must have a decimal point
  • It could be either positive or negative
  • Default sign is positive
  • No commas and blanks are allowed within a Real Constant

The exponential form of representation of real constants is usually used if the value of the constant is either too small or too large. In exponential form of representation the Real Constant is represented in two parts. The first part present before 'e' is called Mantissa and the part following 'e' is called Exponent.


.000342 can be written in Exponential form as 3.42e-4.

Rules for constructing Character Constants

A Character Constant is a single alphabet, a single digit, a special symbol enclosed within a single inverted commas For ex. 'A'

The maximum length a character constant can be 1 character For ex. 'A', 'I', '=' etc.

Previous Home Next