Type of C constants

C constants can be divided into two major categories :
     (a)    Primary Constants
     (b)    Secondary Constants
these constant are further are categorized as shown in in figure.
At this stage, we would restrict our discussion to only primary constants, namely, Integer, Real and Character constants. Let us see the details of each of these constants. For constructing these different types of constants, certain rules have been laid down. These rules are as under.
 
Rules for Constructing Integer Constants

  (a) An integer constant must have at least one digit.
  (b) It must not have a decimal point.
  (c) It can be either positive or negative.
  (d) If on sign precedes an integer constant, it is assumed to be positive.
  (e) No commas or blanks are allowed within an integer constant.
  (f) The allowable range for integer constant is -2147483648 to +2147483647.
Ex :-  482
         +451
          -8000

Rules for Constructing Real Constants

  (a) A real constant must have at least one digits.
  (b) It must have a decimal point.
  (c) It could either positive or negative.
  (d) Default sign is positive.
  (e) No commas or blanks are allowed within a real constants.
                   Real constant are often called Floating point constants. the real constant could be written tn two forms- Fractional form and Exponential form.
Ex :- +352.34
          154.2
           -32.45

Rules for Constructing Character Constants

  (a) A character constant is a single alphabet, a single digit or a single special symbol enclosed         within single inverted commas. both the inverted commas should point to the left.
 For example, 'A' is a valid character constant.
  (b) The maximum length of a character constant can be 1 character.
Ex :- 'A'
         'I'
         '5'

Comments

popular posts

SEMICONDUCTOR DIODE

logical OR Operation

Constants, Variables and Keywords