ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You are asked to find Eulidean distance of some cities. You will be given Latitude and Longitude coordinates of a city and then, two other citites. Find the closer city to the first one.
Input specification
You will be given a string (city name) and two floating point numbers (Latitude and Longitude coordinates of each city) in three lines where (W/E) -180 ≤ Longitude ≤ 180 and (S/N) -90 ≤ Latitude ≤ 90. And, city name is not longer than 15 characters and contains only English letters (no special characters).
Output specification
Show the name of the closer city.
When i run it it doesnt open , it just says this :Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Last edited by beginner lira; 12-05-2014 at 06:43 PM.
In addition...
It is not urgent for the members who volunteer their time to help you with your homework. You have not provided any information as to what is wrong.
I will say that your equation to find distance is wrong. latitude/longitude is usually given in degrees minutes, seconds or degrees, minutes. Are you converting them correctly into degrees. East is plus and west is minus although with only calculating distance it will not make much difference as long as they are all the same.
" it seems that the project isnt build up yet, do you want to build it now ? " - and when i click yes nothing shows up... and this is written in the part where it shows the errors : Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
well you might run into issues with this
" abs(latitudeofthird-latitudeoffirst)"
taking the abs
i am in the Detroit area and depending if one is using "PositiveEast or "PositiveWest"
or if one is using -180 to +180 or 0 to 360
so +83.1 AND -96.9 or E 276.9 Longitude are correct for Detroit
as for notation
BOTH analog and binary are correct
for the center of the telescope mount at the royal observatory
0 deg. 0 min. 0 sec.
and
0.0000000000000
I don't use code blocks and could not find exactly what status 1 means.
The numbers in your last post are not +/-180 and +/-90...
PS.
Since you do not have any text asking for input you probably can not tell that the program was running. When you closed it out it probably gave you that error.
You also might want to change your
scanf ("%f",&distance1);
to a print statement.
I don't use CodeBlocks either, but your code runs fine on the command line. Exit status 1 usually just means a general failure, so it's difficult for anyone to diagnose what went wrong.
Will also have to mention that your calculation is definitely wrong. Example: I live at -179.9999, 0. Friend A live at 179.9999, 0. Friend B lives at 0, 0. I want to visit the friend who lives furthest away from me. Using your formula, Friend A is the furthest away, even though Friend A is probably my next door neighbour.
You need to fix the distance formula and add another calculation step before that (I won't tell you what that is, at least for now).
You might rethink your formula. To calculate dinstances in a 2-dimensional space, you would use Pythagoras' formula -> c^2 = a^2 + b^2, where a = abs(x1 - y1) and b = abs(x2 - y2).
For those who worry about the use of longtitude and latitude, the question only has to answer about the distance, not about in which direction you have to travel.
The point cannot be emphasized enough ... that this is very-plainly homework, and that the intention, not only of "homework" but of the school/class in general, is to teach you the skill of figuring out for yourself what is wrong with your program. It teaches you how to translate a plausible set of requirements (which have in this case been liberally salted with clues) into a functioning program.
This is "the thing that we get paid the big bucks to do."
If you plead for those who do know how to do this, to do this for you, then you are depriving yourself of something that other people are giving both of their money and of their time to provide you. I say this in part because I have taught these courses at community colleges myself, and I didn't do it for the pay.
If, on the other hand, you approach us by saying, "hey, this is homework, and I'm really stuck and this is what I've done so-far and this, specifically, is what I don't understand ..." then many of us will certainly help you. They will strive to help you learn, as will your instructor. (You should be approaching him or her first, partly so that s/he can better gauge the level-of-understanding within the class, so as to fine-tune the instructional approach being taken.)
You have been given the clues that you need to resolve your problem. Without asking for any further clarification, now, go and do it. Yourself. "Practice, practice ..." (And, "patience.") No one around here is saying that it's easy.
Last edited by sundialsvcs; 12-11-2014 at 08:33 AM.
You might rethink your formula. To calculate dinstances in a 2-dimensional space, you would use Pythagoras' formula -> c^2 = a^2 + b^2, where a = abs(x1 - y1) and b = abs(x2 - y2).
For those who worry about the use of longtitude and latitude, the question only has to answer about the distance, not about in which direction you have to travel.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.