Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribedPlease 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 xmax)I if found a larger element max-j; I/move it to the front swap(&x(il. &maxlk

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago