VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-to-find-number-of-solutions-in-quadratic-equation/

⇱ Program to find number of solutions in Quadratic Equation - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to find number of solutions in Quadratic Equation

Last Updated : 30 Aug, 2022

Given an equation with value a, b, and c, where a and b is any value and c is constant, find how many solutions thus this quadratic equation have?
Examples: 
 

Input : Output : 2 solutionsInput : Output : no solution


Solution: 
To check whether the equation has a solution or not, quadratic formula for discriminant is used.
 

The formula is given as, 


Respective conditions are given as, 
 

  • if the discriminant is positive , then the quadratic equation has two solutions.
  • if the discriminant is equal , then the quadratic equation has one solution.
  • if the discriminant is negative , then the quadratic equation has no solution.


Programs: 
 

Output: 

2 solutions

Time Complexity: O(1)

Auxiliary Space: O(1)
 

Comment
Article Tags: