CHALLENGE 2.7.1: Sphere volume. ACTIVITY Given sphereRadius, compute the volume of a sphere and assign sphereVolume with
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
CHALLENGE 2.7.1: Sphere volume. ACTIVITY Given sphereRadius, compute the volume of a sphere and assign sphereVolume with
CHALLENGE 2.7.1: Sphere volume. ACTIVITY Given sphereRadius, compute the volume of a sphere and assign sphereVolume with the result. Use (4.0/3.0) to perform floating- point division, instead of (4/3) which performs integer division. Volume of sphere = (4.0 / 3.0) π r³ (Hint: r³ can be computed using *) (Notes) 413706.2298628.qx3zqy7 1 #include <iostream> 2 #include <iomanip> 3 #include <<math> 4 5 using namespace std; 6 7 int main() { 8 9 10 11 12 13 14 15 16 17 Run | double sphereVolume; double sphereRadius; cin >> sphereRadius; cout << fixed << setprecision (2) << sphereVolume << endl; return 0; Common student error Your code did not use M_PI, a preferred solution uses M_PI. 1 test passed All tests passed