Chapter - 2: C Instructions

Write a program to receive values of latitude and longitude in degrees, of two places on earth and outputs the distance between them in nautical miles. The formula for distance in nautical.


H
Sections
9
Exercises

A

B

C

D

E

F

G

H

1

2

3

4

5

6

7

8

9

10

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
	float l1,l2,g1,g2, D;
	
	printf("\nEnter (two) the values of lattitude : ");
	scanf("%f%f", &l1, &l2);
	
	printf("\nEnter (two) the values of longitude : ");
	scanf("%f%f", &g1, &g2);
	
	D = 3963*acos(sin(l1)*sin(l2) + cos(l1)*cos(l2)*cos(g2-g1));
	
	printf("\nDistance : %f", D);
	
	getch();
	return 0;
}

© 2020 Garbage Valuegarbage value logo