Question: Please answer this soon using C LANGUAGE. Problem 2 (35 points): The file placelist.xt contains the place information (name, country latitude and longitude). Write a
Please answer this soon using C LANGUAGE. Problem 2 (35 points): The file placelist.xt contains the place information (name, country latitude and longitude). Write a C program that a) Reads places from a file called placelist.txt and stores it in an array of type place b) Prints, on screen, places in the database that are NOT in USA c) Sorts the array of places er and print the sorted array on screen. To do so, you will modify the void selection(int x(), int size) function that sorts ints given on the next page. If you hard-code the list of cities sorted by distance in your code, 0 point for this problem. 1) Your program MUST use the following structure: typedef struct place s ( char name [180]; char country[3] double latitude; double longitude; place Note: the above structure can be modified (ie., to include distance) so that it can be used with sorting. 2) The function below should be used to find the distance in miles between 2 locations: (lat1, longl) and (lat2, long2). Note: (lat, long)-(latitude, longitude) double dist (double lat1, double longi, double lat2, double longz) double R-6371; double PI 3.1415926536; double dx, dy, dz; double dist mile long! . long! long2; long1longi(PI18e) lat1-lati(PI 180) lat2 lat2 * (PI / 180); dz sin(lati) sin(lat2) dx-(cos(longi)cos(lat1)) cos(lat2); dy sin(longi)cos(lati) dist mile- (asin(sqrt (dxdxdy dy+dz dz) / 2)*2"R)/1.609344 return dist mile: void selectionint x, int size) void swap/int"x, int y) int i, j; int max for (i-0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
