Q: write a program to receive values of latitude (L1,L2) and longitude (G1,G2) in degrees, of two places on the earth and output the distance (D) between them in nautical miles.

#include <stdio.h>
#include <math.h>

int main()
{
    float D,L1,L2,G1,G2;
   
    printf("enter the value of L1,L2,G1 and G2 in digree :\n");
    scanf("%f%f%f%f",&L1,&L2,&G1,&G2);
   
    /*formula used to find distance between two points on earth in nautical miles*/
    D=3963*(acos(sin(L1*3.14/180)*sin(L2*3.14/180)+cos(L1*3.14/180)*cos(L2*3.14/180)*cos(G2*3.14/180-G1*3.14/180)))*180/3.14;
   
    printf("\ndistance is %f",D);
   
    return 0;
}

-----------------------------------------
output :
enter the value of L1,L2,G1 and G2 in digree :
3
4
5
6

distance is 5599.273438

Comments

Popular posts from this blog

Q: The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate area & perimeter of the rectangle and area & circumference of the circle.

Q: If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)