Every point mass attracts every single other point mass by a force pointing alon
ID: 3882834 • Letter: E
Question
Every point mass attracts every single other point mass by a force pointing along the line intersecting both points. The force is proportional to the product of the two masses and inversely proportional to the square of the distance between them: F = G m_1 m_2/r^2 where: F is the force between the masses: G is the gravitational constant (6.673 times 10^-11 N middot (m/kg)^2): m_1 is the first mass: m_2 is the second mass: r is the distance between the centers of the masses. Write a program that prompts the user to input the masses of the bodies and the distance between the bodies. The program then outputs the force in Newton between the bodies.Explanation / Answer
C++ code for the given problem:
#include<bits/stdc++.h>
using namespace std;
int main()
{
float m1,m2,r;
float G = 6.673*(pow(10,-11)); //initialise value of G
cout << "Enter the value of m1 in kg! ";
cin >> m1; //take input value of m1
cout << "Enter the value of m2 in kg! ";
cin >> m2;//take input value of m2
cout << "Enter the value of r in meter! ";
cin >> r;//take input value of r
float F = G*m1*m2/(r*r);
cout << "The value of F = " << F << " Newton" << endl;
return 0;
}
Sample Output:
Enter the value of m1 in kg!
2
Enter the value of m2 in kg!
5
Enter the value of r in meter!
10
The value of F = 6.673e-012 Newton
Note: If you want the code in any other programming language then comment below, I will change the code!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.