X1 = G_m1_m2 d 2 where G is the universal gravitational constant G = 6.673 x 10-8 cm3 / g sec2 Write a program that reads in the mass of two bodies and the distance between them and then outputs the gravitational force between them and then outputs the gravitational force between them. The output should be in dynes; one dyne equals a g cm / sec2 . Use a constant declaration for G.
#include <stdio.h>
#include <math.h>
int main()
{
const double G=.00000006673;
double m1, m2, d;
printf("Enter the first mass\n");
scanf("%lf", &m1);
printf("Enter the second mass\n");
scanf("%lf", &m2);
printf("Enter the distance\n");
scanf("%lf", &d);
double force = (G*m1*m2)/(d*d);
printf("%lf", force );
return 0;
}
Comments
Leave a comment