C Program to find Roots of a Quadratic Equation

In this tutorial you will learn about the C Program to find Roots of a Quadratic Equation and its application with practical example.

C Program to find Roots of a Quadratic Equation

In this tutorial, we will learn to create a C program that will find the Roots of a Quadratic Equation in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Conditional Statements in c programming.

What is a quadratic expression?

A quadratic equation is an algebraic expression of the second degree in x. The quadratic equation in its standard form is ax2 + bx + c = 0,
where a, b are the coefficients, x is the variable, and c is the constant term.

Algorithm:-

Program to find Roots of a Quadratic Equation.

In this program, we will first take the quadratic equation in input from the user for finding the roots. After taking the input, we will find the root of all three numbers using the mathematical expressions. Then we will print the output roots of the program using the “printf() ” function.

Below is an example of quadratic equations.

With the help of this program, we can check find Roots of a Quadratic Equation.

Program Code:-

 

Output:-

In the above program, we have first initialized the required variable.

  • a, b, c = it will hold the input value of the number.
  • root1, root2, root3 = it will hold the root values for the numbers.

Taking the input numbers from the user for the quadratic equations.

In this section of the code of the program, we will find the roots for the numbers from the input.

Printing the roots of the given numbers by the user.

In this tutorial we have learn about the C Program to find Roots of a Quadratic Equation and its application with practical example. I hope you will like this tutorial.