Example 7: Distance Between the Two Points
Learn how to calculate the distance between two points on Earth.
We'll cover the following
Problem
Write a program that receives latitude values (L1, L2) and longitude (G1, G2) of two places on Earth, in degrees, and returns the distance between them.
The formula for distance in nautical miles is:
D = 3963 * ( + * ( G2–G1 ))
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.