Answer to Question #217582 in C++ for kojo

Question #217582

Using the code stub below, compute the acceleration of gravity for a given distance from the earth's center, distCenter, assigning the result to accelGravity. The expression for the acceleration of gravity is: (G * M) / (d2), where G is the gravitational constant 6.673 x 10-11, M is the mass of the earth 5.98 x 1024 (in kg) and d is the distance in meters from the earth's center (stored in variable distCenter).

#include

using namespace std;

int main() {

double G = 6.673e-11;

double M = 5.98e24;

double accelGravity;

double distCenter;

cin >> distCenter;

/* Your solution goes here */

cout << accelGravity << endl;

return 0;

}


1
Expert's answer
2021-07-17T10:42:06-0400
#include <iostream>
using namespace std;


int main() {
	double G = 6.673e-11;
	double M = 5.98e24;
	double accelGravity;
	double distCenter;
	cin >> distCenter;
	/* Your solution goes here */
	accelGravity = ((G * M) / (distCenter * distCenter));


	cout << accelGravity << endl;
	
	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