write a program to receive value of latitude(l1 and l2) and longitude (g1, g2), in degrees, of two places on the earth and output the distance (d) between them in nautical mile. the formula for distance in nautical mile is - Code With Friends

Breaking

Home Top Ad

Search Your Questions

Friday, February 22, 2019

write a program to receive value of latitude(l1 and l2) and longitude (g1, g2), in degrees, of two places on the earth and output the distance (d) between them in nautical mile. the formula for distance in nautical mile is

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    float lat1, lat2, lon1, lon2, d;
    printf("Enter latitude and longitude of place ");
    scanf("%f %f", &lat1, &lon1);

    printf("Enter latitude and longitude of place ");
    scanf("%f %f, &lat2, &lon2");

    lat1=lat1*3.14/180;
    lat2=lat2*3.14/180;
    lon1=lon1*3.14/180;
    lon2=lon2*3.14/180;

    d=3963*acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1));
    printf("Distance between place 1 and place 2: %f",d);
}



1 comment:

  1. lat1=lat1*3.14/180;
    lat2=lat2*3.14/180;
    lon1=lon1*3.14/180;
    lon2=lon2*3.14/180;
    what are these for??

    ReplyDelete