Search⌘ K
AI Features

Example 7: Distance Between the Two Points

Explore how to calculate the nautical distance between two points on Earth by writing a C program that converts degrees to radians and applies trigonometric functions. Understand the use of acos, sin, and cos functions along with mathematical constants to solve real-world geographic problems.

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 * acosacos ( sinL1sinL2\sin L1 * \sin L2 ...