C Program To Find Quadratic Equation

Overview

In the Quadratic equation in the C program, we will find the roots of the quadratic equations. A quadratic equation is an equation of the second degree, meaning it contains at least one term that is squared. The standard form of the quadratic equation is ax² + bx + c = 0 where a, b and c are real and a!=0, x is an unknown variable. Here, we are going to learn how to find the roots of a quadratic equation using C program? Submitted by Nidhi, on August 03, 2021 Problem Solution: Read the value of a, b, and c, and calculate the roots of a quadratic equation. Program: The source code to roots of a quadratic equation is given below.

In this tutorial, we will write a simple C++ Program to Find Quadratic Equation Roots. The roots for the equation can be calculated as shown below:

Root 1 =

Root 2=

C++ Program

Sample Output

Root 1 := 6 Root 2 := -2 Process returned 0 (0x0) execution time : 2.083 s Press any key to continue.

Enhancements

We can further enhance the program to prompt the input values of a, b, c to the user. Right now we have to modify the code for the values.

Generate the equation string based on the values of a, b, and c and display the equation string in the output.

Take into consideration the imaginary roots if discriminant is less than 0. The logic is outlined in the flowchart link

Quadratic

Flowchart :

The IDE used in the tutorial is Code:: Blocks. To download and install Code Blocks follow the link:

For more information on Code Blocks IDE used in the program , visit the official website of Code blocks IDE: http://www.codeblocks.org/

  • Related Questions & Answers
  • Selected Reading
CServer Side ProgrammingProgramming

We can apply the software development method to solve the linear equation of one variable in C programming language.

C++ Program To Find Quadratic Equation

Requirement

  • The equation should be in the form of ax+b=0
  • a and b are inputs, we need to find the value of x

Analysis

Here,

  • An input is the a,b values.
  • An output is the x value.

Algorithm

Refer an algorithm given below to find solution of linear equation.

Program

C Program To Find Quadratic Formula

Following is the C program to find the solution of linear equation −

Output

C Program To Solve Quadratic Equation

When the above program is executed, it produces the following result −