c2.2 p30 PRACTICE!
Determine which of the following names are valid identifiers. If a name
is not a valid identifier, give the reason that it is not acceptable,
and suggest a valid replacement.
1: density
2: area
3: Time
4: xsum
5: x_sum
6: tax-rate
7: perimeter
8: sec^2
9: degrees_C
10: break
11: #123
12: x&y
13: count
14: void
15: f(x)
16: f2
17: Final_Value
18: w1.1
19: reference1
20: reference_1
21: m/s
c2.2 p31 PRACTICE!
In Problems 1 through 6, express the value in scientific notation.
1. 35.004
2. 0.00042
3. -50,000
4. 3.15723
5. -0.0999
6. 10,000,002.8
In Problems 7 through 12, express the value in floating-point notation.
7. 1.03e-5
8. -1.05e5
9. -3.552e6
10. 6.67e-4
11. 9.0e-2
12. -2.2e-2
c2.2 p35 PRACTICE!
Give the preprocessor directives to assign symbolic constants for these
constants:
1: Speed of light, c = 2.99792 x 108 m/s
2: Charge of an electron, e = 1.602177 x 10-19 C
3: Avogadro's number, N_A = 6.022 x 1023 mol-1
4: Acceleration of gravity, g = 9.8 m/s2
5: Acceleration of gravity, g = 32 ft/s2
6: Mass of the Earth, M_E = 5.98 x 1024 kg
7: Radius of the Moon, r = 1.74 x 106 m
8: Unit of length, Unit_Length = 'm'
9: Unit of time, Unit_Time = 's'