Friday, February 17, 2012

Types of Constants

C constants can be divided into two major categories:

a> Primary Constants
b> Secondary Constants



C constants
_______________________|_____________________
| |
Primary Constants Secondary Constants
| |
1) Integer Constant 1) Array
2) Real constants 2) Pointer
3) Character constants 3) Structure
4) Union
5) Enum. Etc


At this stage, We could restrict our Discussion to only Primary Constants, namely, Integer, Real and Character constants.
For constructing these different types of constants,Certain rules have been laid down.


RULES FOR CONSTRUCTING INTEGER CONSTANTS.

A> An integer constants must have at least one digit.
B> It must not have a decimal point.
C> It can be either positive or negative.
D> If no sign precedes an integer constants, it is assumed to be positive.
E> No commas or blanks are allowed within an integer constants.
F> The allowable range for integer constants is-2147483648 to +2147483647.




The range of an integer constants depends upon the compiler.For example like Visual Studio, gcc, it is -2147483648 to+214748364, whereas for compilers like turbo c or turbo c++ the range is -32768 to +32767.

ex.

426
782
-8000
-7605

No comments:

Post a Comment