Hey guys! I am trying to develop a program that solves second grade equations.
If the equation is for example: x^2 + 2x + 3 = 0, the user has to enter the P and Q value. In this case that would be P = 2, and Q = -3.
Now here is the problem: For everybody who doesn't know, the PQ formula provides 2 values because with this formula you calculate two points of a curved line. My problem is that the only values i recieve back are two really high numbers. I recieve these same values no matter what i put as P or Q. Why is this happening?
If this helps, i am following this specific PQ formula for this program:
i've only had a quick glance, but you have a LOT of uninitialised variables there (lines 7 to 18), which is bad.
I think you're using one of these variables in your code without setting it to something first.
edit: spotted some other stuff:
this: if(P1 < P1)
makes no sense. (also, P1 seems to be one of those variables i mentioned where you're trying to use it without being set.
NOTE: I know that my code is really clunky, but i was lazy, ok?
No, it's really not ok. This may be the root of your problem. You typed up some code that is "clunky", poorly formatted and not commented. And then it doesn't work. So, you come to the forum to find out why the clunky code doesn't work.
Well, I'm too "lazy" to try to debug code for somebody who is too lazy to write non-clunky code in the first place, ok?.
I suspect that if you spend 10 minutes re-formatting the code into something that is less clunky (especially good indentation) and maybe add a comment here or there to let yourself and anyone else looking at the code know what it is doing, you might stumble upon your error in the process and not need to ask the question. When you are about to add a comment and you realize that the code doesn't do what the comment says it's doing, you probably found your bug.
What i ment by "clunky" was actually that i was using some very confusing integer names. And some that i don't use. That doesn't really affect the code's functionality if i have some integers i don't use. But wow, i didn't know there were some really stupid errors. Hahaha i'm sorry. And yes ofcourse, i am going to write it from scratch later.
what ide are you using? i know a lot of them have auto-format options. if you're using visual studio for example, i think it's off the Edit->Advanced menu.
you can also print out the values of your various variables at various stages of the program to see which ones look as expected and which ones don't.
I haven't looked at your code. I've used Dev C++ (not Orwell) for maybe 800 hours doing mathematics. After very exhaustive testing I believe that mathematical errors occur. Large floating point numbers sometimes appear where they do NOT belong!
I'm sorry if this is not directly relative to your situation, but it should be known that this serious situation exists in my opinion. I've probably wasted quite s few hours because of this problem.