In the previous post we have learn about keywords. In this post we will learn about What is Constant they are also part of syntax.
2) Real constant :
Constants
Constant is a value that doesn't change during program execution.Constants are the fixed values.fixed values are also referred as literals.The alphabets,numbers and special symbols when properly combined they forms constants,variable and keywords.Value is stored in memory at free location.
To declare a constant use const keyword
To declare a constant use const keyword
For example (5*a)
In the above example 5 is a constant and 'a' is a variable whose value change during program execution.
Types of constants
Constants are divided into two types as:
1)Primary constants:
C compiler already know the meaning of Primary constants.In C primary constants are three types as
1) Integer constant :
Rules for constructing Integer constants.
1) It should not have a decimal point.
2) An integer constant should have one digit.
3) It can be positive or negative.
4) If no sign precedes as integer constant it is suppose to be positive.
5) No commas or blanks are allowed within an integer constant.
6) The integer constant allowable range is -32768 to +32767.
Rules for constructing Real constants
Real constants are also called as floating point constants.The real constants should be written in two forms as Fractional form and Exponential form.
Following rules should be observed where as constructing real constants expressed in fractional form.
It should have a decimal point.
A Real constant should have one digit.
It can be positive or negative
Default sign is positive.
No commas or blanks are allowed within a Real constant
Example :
+15.54
29.0
-321.58
The exponential type representation of real constants is typically used if the value of the constant is too small or too large.It but doesn't limit us in any way from using exponential form of representation for other real constants.
In exponential type of representation,the real constant is represented two parts.The part appearing before 'e' is called mantissa, whereas the part following 'e' is called exponent.
- Character constant
2)Secondary constants
The definition of secondary constants is defined by the programmer.
0 comments:
Post a Comment