×
☰ Menu

Constants in C

 

Fixed values that do not change during the execution of a program are referred to be constants in C. Constants in C can be separated into two groups:

    • Primary Constants
    • Secondary Constants 

 

Constructing Integer Constants Rules

  • At least one digit is required for an integer constant.
  • It can't have a decimal point in it.
  • It can be either positive or negative.
  • If an integer constant has no sign before it, it is presumed to be positive.
  • Within an integer constant, no commas or blanks are permitted.
  • The range of integer constants that can be used is -32768 to 32767.

Constructing Real Constants Rules

  • Floating Point constants are another name for real constants. The real constants can be expressed in two ways: fractional and exponential.
  • When building real constants in fractional form, the following principles must be followed:
  • At least one digit is required for a real constant.
  • A decimal point is required.
  • It could be either a good thing or a bad thing.
  • Positive is the default sign.
  • Within a real constant, no commas or blanks are permitted.

Character Constants Construction Rules

  • A single alphabet, a single numeric, or a single special sign wrapped in single inverted commas is referred to as a character constant.
  • A character constant can have a maximum length of one character.