Constants in C (continued…)


Constants in C (continued…)

Link to previous post on constant 


Floating point constants :
        Floating pont constants is decimal number that represents a signed real number.
The representation of a floating-point constant an integer portion and a decimal portion or an exponent portion(or both).

Example:
·       0.2
·       827.156
·       500.
·       1.
·       0.00034
·       2E-8
·       0.06e-3
·       1.6667E+8.1212312e12

Floating point constants has a much greater range than integer constants.

The range of floating point is grom 3.4E-38 to 3.4E+38.
Floating point constants are of type float,double,long.
Example :
·       100L(has type long double)
·       100F(has type float)
·       100D(has type double)
A floating point constant with out F or L in suffix is of type double.


Character Constants :
        A character constant is a single character , enclosed with in single quotation mark.
        Example :
·       ‘a’
·       ‘D’
·       ‘3’
·       ‘$’
Character constants have integer values that are determined by the computers particular character set .most computers makes use of ASCII character set, In which each individual character is numerically encoded.
Example:
Constant
Value
‘A’
65
‘x’
120
‘3’
51
‘$’
36
 
32



Character Strings:
A character string or a string constant consist of any number of consecutive characters(including null) enclosed in double quotation marks.
Example :
·       “green”
·       “India”
·       “Hello reader ….”
·       “Dhoni 7 ”
·       “$22.50”
Since a string can be of any length the end of string is marked as ‘\0’ (null character),having ASCII value of 0.
Note that character constant ‘a’ and string constant “a” are not equivalent .

Lets discuss about escape sequences (it comes under character constants) to chin our next post….
Thank you ….

Previous Post
Next Post
Related Posts

0 comments:

Popular Posts