Like Tree1Likes
  • 1 Post By anduril462

I need Immediate help with a problem due in a few hours....

This is a discussion on I need Immediate help with a problem due in a few hours.... within the C Programming forums, part of the General Programming Boards category; Distance on the Earth's surface. Write a program that takes the latitudes and longitudes of two points on the earth's ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    10

    I need Immediate help with a problem due in a few hours....

    Distance on the Earth's surface. Write a program that takes the latitudes and longitudes of two points on the earth's surface and computes the distance between them in nautical miles, miles, and kilometers. The angular distance (delta) between two points is given by:

    cos(delta) = (sin_lat1)(sinlat_2) + (coslat_1)(coslat_2)[cos(long_1 - long_2)]

    This formula assumes that both longitudes are measured either east of Greenwich or west of Greenwich. Multiplying the Angular distance by the radius of the earth gives the surface distance.

    This is A problem I have no clue where to start does anyone have a helpful code solution?

  2. #2
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    Code:
    #include <stdio.h>
    #include <math.h>
    
    int main( void )
    {
            //your code here
            return 0;
    }
    Start there, when you have a problem come back with a more specific question.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,468
    Quote Originally Posted by dmcarpenter View Post
    This is A problem I have no clue where to start does anyone have a helpful code solution?
    Nope, no helpful code solutions. Giving away code, especially for a homework problem (which, if you only have a few hours left, sounds like nothing but poor time management on your part), is in direct violation of our forum guidelines and homework policy. What I can do, is give you a list of "steps" to follow, ways to make small but useful progress towards a solution.

    1. Ask the user for two sets of coordinates. Print them back to verify you read them correctly.
    2. Calculate the angular distance (delta) using the formula above, and the sin() and cos() functions, and the latitude and longitude points you were given. Print it to verify.
    3. Pay careful attention to the documentation for the sin and cos functions (link for cos -- sin is similar). Notice that they expect angles in radians, not degrees, so convert. If you don't know how, Google can help you.
    4. Find the radius of the earth in whatever units you want: knots, miles, kms. Multiply by delta and print that out to verify.
    5. Realize that knots, miles and kms are all linear distance units, so converting from any one to another simply requires multiplying by the right conversion factor. Google for that conversion factor.
    6. Multiply your distance from step 3 by the conversion factors in step 4 to get the distance in the other two units.
    Salem likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-07-2012, 09:00 AM
  2. 7 hours?
    By Jeffery in forum C Programming
    Replies: 1
    Last Post: 10-10-2010, 02:49 AM
  3. i tried myself for 2 hours but failed.
    By epidemic in forum C++ Programming
    Replies: 0
    Last Post: 04-02-2007, 05:46 PM
  4. 40 hours and counting..
    By GSLR in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 03-19-2003, 07:51 PM
  5. How many hours/day at cprogramming.com ?
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 01-28-2003, 10:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21