Basics in C - 2

In this session we shall see rules for constructing integers constants. It may see to you what we are talking about...but you will soon understand everything. You just need to keep the points that we have covered in basics sessions.

Rules for Constructing Integer Constants

  1. An integer constant must have at least one digit.
  2. It must NOT have a decimal point.
  3. It can be positive or negative.
  4. By default, integer is assumed to be positive.
  5. No commas or blanks should be used within the integer constant.
  6. Allowable range is -32768 to 32767
Range actually depends upon the compiler. Above mentioned range is for  16 bit compiler like Turbo C++ that we are going to use. For 32-bit compiler the range would be much greater. But we shall start with most basic compiler and then grow.

Rules for Constructing Real Constants

  • Real constants are also called floating point constants.
  • Real constants are written in two ways - Fractional form and exponential form.
Following rules should be observed while constructing real constants:
  1. A real constant must have atleast one digit.
  2. It must have a decimal point.
  3. It can be positive or negative.
  4. Default sign is positive.
  5. No commas and blanks are allowed within a real constant.
To understand the exponential form please see the video below:

Rules for Constructing Character Constants

  1. It should be a single alphabet or symbol enclosed within single inverted comma. E.g 'A'
  2. Maximum length of character constant can be one character. So 'AB' is INVALID.

No comments:

Post a Comment