Type of C Contants

C Contants are of following Types:-

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                   
PartTypeSign
MantissaInteger Part of Real NumberHas Optional +/- Sign
ExponentPower of 10Has Optional +/- Sign


Note :
  • Exponent Part Should be Always Integer.
  • Default Sign is Positive for both Mantissa as well as Exponent
  • Special Characters not allowed
  • Spaces are not allowed
Illustrative Examples :
Real NumberRepresentation
4567.454.56745e3
0.000454.5e-4
  
Consider Example 2 :
  • Mantissa Should be in between 1 to 9
  • Number : 0.00045 so shift decimal Point to Right by 4 Digit to obtain Mantissa as 4.5 
  • Decimal Point is Shifted 4 times to Right 
  • According to above Fig . Real Number : 4.5 e -4
Type of C Contants Type of C Contants Reviewed by ANAND PANDEY on 7:57:00 AM Rating: 5

No comments:

Created By Anand Pandey. Powered by Blogger.