Constants in C language | what is Constant and Different types of Constants
Constant is value that cannot be changed during execution of program. in other words It is Fixed one never be changed during the program execution.
Constants are classified into three types those are,.
- Numeric Constants.
- Character Constants.
- String Constants.
Numeric Constants :
Numeric Constants are contains Numbers they may have fractional part or may not have fractional part(Decimal Part).
C have few rules to construct Numeric constants those are
- Numeric constant should have at-least one digit.
- No comma are Space is allowed within the Numeric Constant.
- Numeric Constants are positive or Negative if you don’t specify any sign default sign is Positive.
Again Numeric constants are further classified into two types
- Integer Constants.
- Decimal Constants.
Integer constants are all Numbers which doesn’t contains Decimal Point (.).
Ex : 431, 85, 65, 31….etc.
Real Constants are Numeric constants that contains Decimal Point.
Real Constants also called as Floating point Constants. The real constants can be written in two forms, Fractional form and Exponential form.
Ex : 0.7, 4.31, 98.2,…etc. ( Fractional representation ).
Ex : +4.3e-5, 1.2e+5,…etc. ( Exponential Representation ).
Character Constants :
A Character Constant is single character it is enclosed by the single quotes ( ‘ ‘ ).
some Valid character constants are ‘M’ ‘V’ ‘4’ ‘$’ ‘