C Constants Types

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Primary Constant :

  • Integer
  • Float
  • Character

Secondary Constant :

  • Array
  • Pointer
  • Structure
  • Union
  • Enum

Rules of Constructing Integer and Float Constant

Sr.No Rule Integer  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

 

6 Max Value

 

+32767

 

3.4e38

 

Format of Real Number Constant :

Syntax :                                 mantissa e exponent                   

Part Type Sign
Mantissa Integer Part of Real Number Has Optional +/- Sign
Exponent Power of 10 Has 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 Number Representation
4567.45 4.56745e3
0.00045 4.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