Types of Constants : C Programming Language



Primary Constant :

  • Integer
  • Float
  • Character

Secondary Constant :

  • Array
  • Pointer
  • Structure
  • Union
  • Enum

Rules of Constructing Integer and Float Constant
Sr.NoRuleInteger  Float
1

Decimal Point

Not Allowed

Allowed

2

Sign

Positive or Negative

Positive or Negative
3

Default Sign

Positive

Positive
4

No of Digits

At least 1

At least 1
5

Min Value

-32768

-3.4e38

6Max Value

+32767

3.4e38

Format of Real Number Constant :
Syntax :                                 mantissa e exponent                   
Part
Type
Sign
MantissaInteger Part of Real NumberHas Optional +/- Sign
ExponentPower of 10Has Optional +/- Sign


Note :
  1. Exponent Part Should be Always Integer.
  2. Default Sign is Positive for both Mantissa as well as Exponent
  3. Special Characters not allowed
  4. Spaces are not allowed

Illustrative Examples :

Real NumberRepresentation
4567.454.56745e3
0.000454.5e-4

 

Consider Example 2 :
  1. Mantissa Should be in between 1 to 9
  2. Number : 0.00045 so shift decimal Point to Right by 4 Digit to obtain Mantissa as 4.5 
  3. Decimal Point is Shifted 4 times to Right 
  4. According to above Fig . Real Number : 4.5 e -4