Constants In C language


Constants are the terms that cannot be change during program execution. Constants can be classified as :

Integer constants

Integer constants are the constants in which there is no any fractional part.

Rules for Constructing Integer Constants

  • An integer constant must have at least one digit.
  • It must not have a decimal point.
  • It can be either positive or negative.
  • If no signed precedes an integer constant, it assumed to be positive.
  • No commas or blanks are allowed within a integer constant.
  • The allowable range for integer constants is -32768 to 32767.

Floating-point constants

Fractional constants are the constants that have either fractional part or exponent form.

Rules for Constructing Real/Float Constants

  • 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 or blanks are allowed within a real constant.

Character constants

A character constant is a single alphabet, a single digit or a single special symbol enclosed with single inverted commas i.e. ‘a’, ‘1’, ‘$’.

Rules for Constructing Character Constants

  • A character constant can only have a single digit, alphabet, or a special symbol.
  • It must enclosed within single inverted commas. Both the inverted commas should point to the left.
  • The maximum length of a character constant can be 1 character.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s