Constants in ‘C’
A) Numeric Constant
1) Integer Constant:-
They are whole number without any fractional part. They are represented by keyword (int). The default sign is (+)ve positive. But integer can be positive or negative. The range of integer constant depends upon the machine there are two type of integer constant, namely signed and unsigned.
The signed integer can be positive or negative but the unsigned integers are always considered as positive.
In order to provide some control over the range of integer and the available storage space. There are 3 classes of integers in ‘C’
i) Short int
ii) Int
iii) Long int (both signed & unsigned)
2) Real Constant:-
These are the constants which can have a decimal notation. The default signed is positive but number can be negative. They are represented by keyword (float). Hence they are also called as floating point or floating numbers. These numbers can also be represented in the exponential or scientific format as follows
mantissa e exponent |
OR
|
mantissa E exponent |
B) Numeric Constant:
1) Character constant:-
It is any single character enclosed in a pair of single quotes For eg:- ‘A’ ‘+’ ‘w’ ‘0’ etc.
Each character constant has a fixed integer value in ‘C’. These values are the ASCII values as the character constant have values it is possible to do Arithmetic operation on them.
2) String Constant:-
It is any sequence of character in ‘C’ enclosed in a pair of double quotes. It can be of any length. These constant are mainly use in programs. A compailer automatically places a null character \o at the end of every string constant.
Note that this null character cannot be seend on the monitor when the string in display on it.
0 comments:
Post a Comment