Saturday, 3 September 2016

Constants


Constant.

Constant is an entity that does not change during program execution. Example when we write number=10 than 10 is constant in all program and never change value.

There are mainly two types constants
  1. Primary constants.
1.Integer constant
2.Real Constant
3.character Constant

     2.  Secondary Constants.

1.Array
2.Structure
3.Pointer
4.Union

* Rules for construction Integer Constant.

1. At least one digit must have an integer constant.
2.It can be positive or negative. The general range of integer constant is -32768 to +32767.(NOTE : Normally range depend on compiler.)
3.No commas or blank spaces are allowed within integer constant.
4.Integer constant must not having decimal point.
5.Example of integer constant are as 364,-66,+786,-1

* Rules for constructing Floating point or Real constant.

1.At least one digit must have an real constant.
Real constant must have decimal point.
2.It may be positive or negative.
3.No commas or blank spaces are allowed within real constant.
4.Example of real point constant : +23.0, 786.786, -0.786, 0.0

 * Rules for constructing Character constant.

1.Any single entity(like as single alphabet, single digit or single symbol) are enclosed within single inverted commas, are called character constant.
2.Example of Character constant : 'a', 'A', '*', '4' etc..

No comments:

Post a Comment