Find Roots of Quadratic Equation C Program

By | May 18, 2016

C Program To Find Roots of Quadratic Equation

Learn How To Find Roots of Quadratic Equation in C Programming Language using If – Else Block Structure. This Code To Calculate Quadratic Roots of an Equation is without Functions and also has an Output Screen displayed at the bottom of this page.

What is a Quadratic Equation?

The Standard Form of a Quadratic Equation is ax2 + bx + c = 0, where x is a variable entity and a, b, c are constant values which cannot be changed.

Formula For Quadratic Equation

z = −b ± √(b2 − 4ac) / 2a

Conditions For Discriminants

  • If b2 − 4ac is Negative, Two Complex Solutions are possible
  • If b2 − 4ac is Positive, Two Real Solutions are possible
  • If b2 − 4ac = 0, One Real Solution is possible

Also Read: C Program To Remove Vowels From A String

C Program To Find Roots of Quadratic Equation

 

Note: If you Compile this Code in Linux, you will get a Linker Error. It is because the implementation of sqrt() method is missing and it is defined in libm library in GNU GCC Compiler. Therefore, you have to explicitly apply it while compilation.

Command: gcc test.c -lm

Also Read: Find Sum of Lower Triangular Elements of Matrix C Program

 

Output

C Program To Find Roots of Quadratic Equation using If Else

If you have any compilation errors or doubts in this Program to Find Roots of Quadratic Equation in C Programming Language, let us know about in the Comment Section below.

One thought on “Find Roots of Quadratic Equation C Program

  1. Mahesh Asalkar

    It is really a short and simple code for finding quadratic roots in c language. Thanks.

    Reply

Let's Discuss