Saturday, December 5, 2009

1.6 CONSTANTS

There are four basic type of constants in C.They are integer constants,floating point constants,character constants and string constants.

The following rules apply to all numeric type constants.

1.Commas and blank spaces cannot be included within the constant.
2.The constant can be preceded by a minus (-) sign if desired.
3.The value of a constant cannot exceed specified minimum and maximum bounds.

Example of valid constants are:

0,5280,999-->integer constants
1.,827.65,2E-8,.1234e12-->floating point constants
'a','X','?','7'-->character constants
"yellow","20.05","washington,dc 2006"-->string constants

invalid constants:

12,345-->illegal character (,)
30 40 50-->illegal character (blank space)
145-654-552-->illegal character (-)
0354-->first digit cannot be zero

No comments:

Post a Comment