Click here to Skip to main content
12,697,340 members (27,414 online)
Click here to Skip to main content
Alternatives (7)
Add your own
alternative version

Tagged as


3 bookmarked

A simple program to solve quadratic equations with

, 11 Nov 2010 CPOL
A simple program to calculate quadratic equation with.Input MUST have the format:AX2 + BX + C = 0EXAMPLE: input the equation 2X2 + 4X -30 = 0 as:A= 2 B= 4 C= -30The answers for AX2 + BX + C = 0 should be 3 and -5.x1=3x2=-5 bool solver(float...


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

16 Nov 2010
Alain Rist
I prefer this :) #include #include #include #include static const double bad_double = std::numeric_limits::quiet_NaN();class QuadSolver{ static bool IsZero(double val) { return (val == 0) || (fabs(val) <...
8 Nov 2010
Anshul R
Simple and prints imaginary roots too!float a,b,c,x1,x2,d,dsq;printf("ax^2 + bx + c = 0");printf("\nEnter a,b,c separated by commas : \n");scanf("%f,%f,%f",&a,&b,&c);d = b*b-(4*a*c);if(d>=0){dsq=sqrt(d);x1 = (-b+dsq)/(2*a);x2 = (-b-(dsq))/(2*a);printf("\nRoot 1 : %f\nRoot 2...
9 Nov 2010
// Real solutions of the quadratic equation A x^2 + B x + C = 0// Returns two roots (possibly identical) in increasing order, or nonebool Quadratic(double A, double B, double C, double R[2]){ if (A == 0) { // Linear, impossible or degenerate, cannot find two roots ...
10 Nov 2010
The correct way to solve quadratic equations is none of the above. For the correct algorithm as applied in the following function, seenumerical recipes in C and the Wolfram site at bool quadratic(double a, double b,...
20 May 2010
#include #include #include "Raiz_Cuadratica.h"int main(){ // float xx = 1; float x = 1; float i = -12; RaizCuadratica *lala = new RaizCuadratica( xx, x, i ); RaizCuadratica::sRaiz raiz = lala->GetRaiz(); printf( "x1 = %f || x2 = %f\n\n",...
7 Nov 2010
15 Nov 2010
Michael Waters
I am reposting this because I accidentally deleted my first post.The solution is presented as a pair of complex roots, unless a == 0, in which case the equation is linear and returns a single complex(real) root.If a == 0 and b == 0, the function fails.Given a complex type, replace...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

About me:
I attended programming college and I have a degree in three most famous and successful programming languages. C/C++, Visual Basic and Java. So i know i can code. And there is a diploma hanging on my wall to prove it.
I am a professional, I am paid tons of cash to teach or do software development. I am roughly 30 years old .

I hold lectures in programming. I have also coached students in C++, Java and Visual basic.

In my spare time i do enjoy developing computer games, and i am developing a rather simple flight simulator game
in the c++ programming language using the openGL graphics libray.

I've written hundreds of thousands of code syntax lines for small simple applications and games.

| | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 11 Nov 2010
Article Copyright 2010 by Software_Developer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid