72.2k views
3 votes
Compute the acceleration of gravity for a given distance from the earth's center, dist_center, assigning the result to accel_gravity. the expression for the acceleration of gravity is: (g * m) / (d 2), 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 dist_center). sample output for the given program: 9.803495445209855

1 Answer

3 votes
#include <iostream> using namespace std; int main() { double G = 6.673x10^-11; double M = 5.98x 10^24; double accelGravity = 0.0; double distCenter = 0.0; dist_center = 6.38x10^6; accelGravity = (G*M)/(distCenter *distCenter); cout << "accelGravity: " << accelGravity << endl; return 0; }
User Jorg
by
8.7k points