**Introduction to Gravitational Force**

We know that gravity is universal. According to Newton’s Law of Universal Gravitation, all objects attract each other with a force of gravitational attraction. According to this law, the force of gravitational attraction is directly dependent upon the masses of both objects and inversely proportional to the square of the distance that separates their centers. On removing the proportionality sign, we add G, the Universal Gravitational Constant. This can be reduced to the following equation:

**F= Gravitation force of attraction between two objects in newton(N)
G=Universal Gravitational Constant()
m1 and m2 = Mass of two objects(Kg)
r= separation in meters(m) between the objects,as measured from their centres of mass.**

Examples:

Input: m1 = 20000000 kg m2 = 4000000 kg r = 15 m Output : The Gravitational Force is: 23.73 N Input: m1 = 5000000 kg m2 = 900000 kg r = 30 m Output : The Gravitational Force is: 0.33 N

The approach is simple. We will just use the formula mentioned in the Introduction.

`# Python code to find Gravitational Force ` `def` `force(m1, m2, r): ` ` ` `G ` `=` `6.673` `*` `(` `10` `*` `*` `-` `11` `) ` ` ` `F ` `=` `(G` `*` `m1` `*` `m2)` `/` `(r` `*` `*` `2` `) ` ` ` ` ` `# Rounding to two digits after decimal ` ` ` `return` `round` `(F, ` `2` `) ` ` ` `# Driver Code ` `m1 ` `=` `5000000` `m2 ` `=` `900000` `r ` `=` `30` `print` `(` `"The Gravitational Force is: "` `, force(m1, m2, r), ` `"N"` `) ` |

*chevron_right*

*filter_none*

Output:

The Gravitational Force is: 0.33 N

## Recommended Posts:

- Time until distance gets equal to X between two objects moving in opposite direction
- Passing and Returning Objects in Java
- C++ Classes and Objects
- Maximum number of objects that can be created as per given conditions
- Classes and Objects in Java
- Program to find the percentage of difference between two numbers
- Program to calculate distance between two points
- Program to calculate distance between two points in 3 D
- Program to find GCD or HCF of two numbers
- Program to find LCM of two numbers
- Program to find smallest difference of angles of two parts of a given circle
- Program to find GCD or HCF of two numbers using Middle School Procedure
- Program to find the LCM of two prime numbers
- C Program to Swap two Numbers
- Program for addition of two matrices
- Program to check if two given matrices are identical
- Program to check congruency of two triangles
- C Program to Add two Integers
- C Program to Multiply two Floating Point Numbers
- Program to Add Two Complex Numbers

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.