C/C++ has 5 basic types of data, with specific sub-types as follows:
Decimal: [±]1-9[0-9...][Ll][Uu]
Octal: [±]0[0-7...][Ll][Uu]
Hexadecimal: [±]0x[0-9a-fA-F...][Ll][Uu]
[±]1-9[0-9...].[0-9...][Ee[±]0-9...][FfLl] [±][0].[0-9...][Ee[±]0-9...][FfLl] [±]1-9[0-9...]Ee[±]0-9...[FfLl] [±]1-9[0-9...]Ff[Ll]
For each of the constants in the following table, indicate whether the constant is legal or illegal, what type of constant it is if legal, and why illegal otherwise:
| Constant | Legal? |
Explanation |
486 |
|
|
98.6 |
|
|
98.6f |
|
|
02.479 |
|
|
0.2479 |
|
|
"A" |
|
|
'A' |
|
|
'ABC' |
|
|
'\n' |
|
|
000042 |
|
|
0ffH |
|
|
0xC2F9 |
|
|
+37.1 |
|
|
.0000 |
|
|
0xFLU |
|
|
0x48.6 |
|
|
0x486e1 |
|
|
486e1 |
|
|
0486e1 |
|
|
0486 |
|
|
average = ( double ) total / nStudents;
average = double( total ) / nStudents;
The following topics are not covered here, but may be found in many books on C/C++;