Posted under C++ & Programming
I’m still a beginner at programming. I have not really decided if I want to learn ruby or c++, but for now I think c++ is more versatile. Anyway, I have made a little program that solves quadratic equations, with both real and complex solutions.
The quadratic formula itself can be found in my post Solve quadratic equations with php. The difference between the solving in these two cases, is that the php-solver do not solve the equation if the solution is complex.
Until I figure out a smart way to display nice looking code in my posts, the code can be found here. If you are familiar with c++, you should understand quite easy. I don’t think it is to difficult if you are familiar with another programming language, or programming in general either.
Download the program. Don’t worry about it being and .exe-file, even though they potentially are dangerous. This one is perfectly safe to download and use. Show care when downloading from the Internet.
I use Code Blocks when programming in c++, both for editing and compiling.
Php Program Language on 25 Jun 2008 at 4:20 pm #
The other two methods, the quadratic formula and completing the square, will both work flawlessly every time, for every quadratic equation. Php Program Language
Lai Alexander on 27 Jun 2008 at 8:40 pm #
What exactly do you mean? Of course the quadratic formula works every time, but when you have the square root of a negative number, you have to know how to calculate the complex number from there. A computer program wont solve the problems with complex solutions, unless you have programmed it to do so. My little snippet in PHP is NOT programmed to give you a complex solution, however, this program, which is written in C++, will give you the complex solutions if that is the case for that particular equation.
Soares Adelani on 06 Nov 2008 at 9:34 pm #
Hi, could u please help me write a c++ code that solve the square root of negative numbers. God Bless You
Lai Alexander on 07 Nov 2008 at 12:30 am #
That shouldn’t be a problem, that’s actually fairly easy, a lot less coding than in the program mentioned in this article. Do you know the math behind it? Do you know what “i”, as in the imaginary unit, means? And you just so I’m not mistaken, you mean a program that finds the square root of negative numbers? I’m kind of busy right now, so give me a day or two, and I shall make a post about it.