Innocent PAUL
Last updated:
1 minutes read

Quadratic equation solver program

innogistblog.com
Cover Image for Quadratic equation solver program

In this article will be looking at how to build a quadratic equation solver program.
We'll be building the Algorithm first and then followed by choosing a program which we are comfortable with to run the the the program.

What is an Algorithm

An algorithm is a step-by-step instruction written to solve a given problem.
It is recommended to write an algorithm before writing the main code for some of the advantages is that it helps to visualise the steps that will be required for the program to work perfectly and efficiently and it makes the the work of a programmer faster.

Algorithm to solve Quadratic Equation

1. Start

2. Input a, b, c

3. d = (b*b) - 4*a*c

4. root1 = -b/(2*a) + sqrt(-d)/(2*a)

5. root2 = -b/(2*a) - sqrt(-d)/(2*a)

6. If(d < 0)
6.1 Output "The roots of the equation are complex numbers which are: \n"
6.2 Output root1, root2

7. Else if(d == 0)
7.1 root = -b/(2*a)
7.2 Output "The roots of the equation are equal which is: "
7.3. Output root

8. Else
8.1 Output "The roots of the equation are real numbers which are: \n"
8.2 Output root1, root2

9. Stop

You can find the code sample written in JavaScript here

Subscribe to our Newsletter.

Comments:


  • Innocent Paul (Last updated: )

    Please update this post



  • Benjamin David (Last updated: )

    Like to build a quadratic equation



  • Innocent Paul (Last updated: )

    @Ben, what's your stress 😁




More Stories

Cover Image for How to Use Git in a Real Project

How to Use Git in a Real Project

Last updated:
Cover Image for Get started with Git

Get started with Git

Last updated:
Cover Image for steps to install Git on windows

steps to install Git on windows

Last updated: