[Tutorial 7] 5.Which of the following are invalid constants? Why?

123.456               0996
0x10.5                -12E-12
0X0G1                07777
0001                    1234uL
0xFFFF               1.2Fe-7
123L                    15,000
0Xab05               1.234L
0L -597.25          197u
123.5e2               100U
.0001                   0XABCDEFL
+12                     0xabcu
98.6F                  +123
98.7U
17777s


1. `123.456`: Valid decimal floating-point number.
2. `0x10.5`: Invalid due to the '.' in a hexadecimal literal.
3. `0X0G1`: Invalid due to 'G' in a hexadecimal literal.
4. `0001`: Valid octal integer.
5. `0xFFFF`: Valid hexadecimal integer.
6. `123L`: Valid decimal long integer.
7. `0Xab05`: Valid hexadecimal integer.
8. `0L`: Valid decimal long integer.
9. `-597.25`: Valid decimal floating-point number.
10. `123.5e2`: Valid decimal floating-point number in scientific notation.
11. `.0001`: Valid decimal floating-point number.
12. `+12`: Valid decimal integer.
13. `98.6F`: Invalid suffix 'F' for a numeric literal.
14. `98.7U`: Invalid suffix 'U' for a numeric literal.
15. `17777s`: Invalid suffix 's' for a numeric literal.
16. `0996`: Valid octal integer but may be interpreted differently due to the leading '0'.
17. `-12E-12`: Valid decimal floating-point number in scientific notation.
18. `07777`: Valid octal integer.
19. `1234uL`: Invalid due to improper combination of 'u' and 'L'.
20. `1.2Fe-7`: Invalid due to unrecognized suffix 'Fe'.
21. `15,000`: Invalid due to the comma within the number.
22. `1.234L`: Valid decimal long floating-point number.
23. `197u`: Invalid due to incomplete syntax.
24. `100U`: Invalid due to incomplete syntax.
25. `0XABCDEFL`: Valid hexadecimal long integer.
26. `0xabcu`: Invalid due to incomplete syntax.
27. `+123`: Valid decimal integer.

So, among the given constants, the invalid ones are: 2, 3, 13, 14, 15, 19, 20, 21, 23, 24, and 26.

Comments

Popular posts from this blog

Introduction To C

First C Program

Compilation process in c