i) Numeric constants
A. Integer Constants: An integer constants refers to a sequence of digits.
There are three types of integers decimal, octal and hexadecimal.
Decimal integers consist of set of digits, 0 through 9, preceded by an optional – or + sign.
Examples: 456
-253
0
98767
+4734
Embeded space, commas, and non-digit characters are not permitted between digits.
Examples: 65 896
45,7665
$867
All are illegal numbers.
Octal integer: consists of any combination of digits from the set 0 through 7, with a leading 0.
Examples: 045
0
0768
Hexadecimal integer: A sequence of digits preceded by 0x or 0X is considered as hexadecimal ineteger. They may also include alphabets A through F or f. The letters A through F represent the numbers 10 through 15.
Examples:
0X5
0X76F
0xbcd
B. Real Constants: Quantities are represented by numbers containing fractional parts are called real or floating point constants.
Examples: 0.0056
+34.675
-53.46
-0.89
It is possible to omit digits before the decimal points, or digits after decimal point.
Examples: +.467
634.
-.53
An real number may also be written in exponential or scintific notation. The value 534.89 may be written as 5.3489e2 in an exponential notation.
ii) Character constants:
A. Single character constants: Contains a single character enclosed within a pair of single quote marks.
Examples: ‘d’ ‘7’ ‘T’ ‘;’ ”
Note that the character constant ‘7’ is not the same as the number 7. The last constant is a blank space.
Character constants have integer values know as ASCII values. For example,
printf(“%d”,’a’);
would print the number 97, the ASCII value of the letter a. Similarly, the statement
printf(“%c”,97);
would print the letter ‘a’.
B. String constants: is a sequence of characters enclosed in double quotes.
The characters may be letters, numbers, special characters and blank space.
Examples: “How Are You?” “7+2” “5” “d”