Answer to Question #99400 in C++ for Caleb

Question #99400
Given sphereRadius and piVal, 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) π r3 (Hint: r3 can be computed using *)
1
Expert's answer
2019-12-16T05:40:14-0500
#include<iostream>

using namespace std;

int main() {
	double sphereRadius;
	double piVal = 3.141592;

	cin >> sphereRadius;

	double r3 = sphereRadius * sphereRadius * sphereRadius;
	double sphereVolume = (4.0 / 3.0) * piVal * r3;

	cout << sphereVolume;

	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS