The constant which consist of number digits and have least one digit, with no comma or space, with positive or negative sign and may or may not have decimal point (.) is called Numeric constant.
There are two types of two types they are;
- Integer constant
The whole numbers which have no faction part (decimal point) is called integer http://electronicsprogramming.com/uncategorized/constants/. There are three types of integer constant which are allowed in C are;
- Decimal constant ————–base 10.
- Octal constant——————-base 8.
- Hexadecimal constant———base 16.
The allowed digits under integer constant are;
0,1,2,3,4,5,6,7,8,9,10 ——————— Decimal constant.
0,1,2,3,4,5,6,7 —————————— Octal constant.
0,1,2,3,4,5,6,7,8,9,10 ——————— Hexadecimal constant.
A,B,C,D,E,F,a,b,c,d,e,f
#..Some valid decimal constant are;
0 , 1 , 19 , 672 , 9999, 30000
And following are the invalid decimal integer constants are;
18#3, 1(blank) 9, 55.5, 082, 182, 6, 7-4+56
In above example, character (#), blank space,(.) , (,),(-+) are illegal characters and 0 cannot be the first digits of decimal integer constants…
#..Octal integer constant stats from digits of set 0 to 7 but its digits must be starts for 0. For example;
0856
0
01
081102
So some invalid octal integers constant are;
4402————-Does not begin with 0.
0586————-8 is not an octal digits.
077.21———–Decimal point not allowed.
-0#76————-Illegal character (-, #).
#..A hexadecimal constant must have at least one hexadecimal digit and starts with ox or OX. It may have either + or – sign.
Some valid hexadecimal constants are;
OX52
OX89
-ox0725
+0x85210E
And some invalid hexadecimal constant are;
14AF—————–Does not begin with ox or OX.
OX 4905Bh ———‘h’ is not a hexadecimal digit.
0x.4bcde ———— Illegal character (.).
- Real constants or floating point.
A floating point constant is a base-10 numbers those constants either a fraction form or the exponent or the both. It may have either sign (+,-).
#..Some valid floating points are as given;
0.5 , 11.0 , 8905.2, 4000. , 66668e2 , -52.34 ,-o.123
#..The following are some invalid floating point constant;
85——————– Missing decimal point (.).
-1/2——————- Illegal characters(/).
.59,45.4—————Illegal character(.,,) and no digits to left of the decimal point.
#..Some valid floating pint constants in the exponent forms are given below.
8.85e5——is equivalent to 88500.
6.6E2——–is equivalent to 660.
5.3e-6——-is equivalent to -530000.
so According to this rule