Given three numbers **A, B, C** which represents the coefficients(constants) of a quadratic equation , the task is to check whether one root of the equation represented by these constants is twice of other or not.

**Examples:**

Input:A = 1, B = -3, C = 2

Output:Yes

Explanation:

The given quadratic equation is

Its roots are (1, 2).

Input:A = 1, B = -5, C = 6

Output:No

Explanation:

The given quadratic equation is

Its roots are (2, 3). or

**Approach:** The idea is to use the concept of quadratic roots to solve the problem. We can formulate the condition required to check whether one root is twice of the other or not by:

- The sum of roots = + = 3. This value is equal to:

- Similarly, the product of the roots = * = 2. This value is equal to:

- We can solve the above two equations and to get the condition:

- Therefore, inorder for the first assumption of the roots to hold true, the above condition needs to hold true. Hence, we simply check if the above condition is true or not for the given coefficients.

Let the roots of the given quadratic equation be and .

Below is the implementation of the above approach:

## C++

`// C++ program to check if one root ` `// of a Quadratic Equation is ` `// twice of other or not ` ` ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// Function to find the required answer ` `void` `checkSolution(` `int` `a, ` `int` `b, ` `int` `c) ` `{ ` ` ` `if` `(2 * b * b == 9 * a * c) ` ` ` `cout << ` `"Yes"` `; ` ` ` `else` ` ` `cout << ` `"No"` `; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `a = 1, b = 3, c = 2; ` ` ` ` ` `checkSolution(a, b, c); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to check if one root ` `// of a quadratic equation is ` `// twice of other or not ` `class` `GFG{ ` ` ` `// Function to find the required answer ` `static` `void` `checkSolution(` `int` `a, ` `int` `b, ` `int` `c) ` `{ ` ` ` `if` `(` `2` `* b * b == ` `9` `* a * c) ` ` ` `System.out.print(` `"Yes"` `); ` ` ` `else` ` ` `System.out.print(` `"No"` `); ` `} ` ` ` `// Driver Code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `a = ` `1` `, b = ` `3` `, c = ` `2` `; ` ` ` ` ` `checkSolution(a, b, c); ` `} ` `} ` ` ` `// This code is contributed by shubham ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to check if one root ` `# of a Quadratic Equation is ` `# twice of other or not ` ` ` `# Function to find the required answer ` `def` `checkSolution(a, b, c): ` ` ` ` ` `if` `(` `2` `*` `b ` `*` `b ` `=` `=` `9` `*` `a ` `*` `c): ` ` ` `print` `(` `"Yes"` `); ` ` ` `else` `: ` ` ` `print` `(` `"No"` `); ` ` ` `# Driver code ` `a ` `=` `1` `; b ` `=` `3` `; c ` `=` `2` `; ` `checkSolution(a, b, c); ` ` ` `# This code is contributed by Code_Mech ` |

*chevron_right*

*filter_none*

## C#

`// C# program to check if one root ` `// of a quadratic equation is ` `// twice of other or not ` `using` `System; ` `class` `GFG{ ` ` ` `// Function to find the required answer ` `static` `void` `checkSolution(` `int` `a, ` `int` `b, ` `int` `c) ` `{ ` ` ` `if` `(2 * b * b == 9 * a * c) ` ` ` `Console.WriteLine(` `"Yes"` `); ` ` ` `else` ` ` `Console.WriteLine(` `"No"` `); ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `a = 1, b = 3, c = 2; ` ` ` ` ` `checkSolution(a, b, c); ` `} ` `} ` ` ` `// This code is contributed by shivanisinghss2110 ` |

*chevron_right*

*filter_none*

**Output:**

Yes

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Check if roots of a Quadratic Equation are reciprocal of each other or not
- Least root of given quadratic equation for value greater than equal to K
- Check if roots of a Quadratic Equation are numerically equal but opposite in sign or not
- Smallest root of the equation x^2 + s(x)*x - n = 0, where s(x) is the sum of digits of root x.
- Program to find number of solutions in Quadratic Equation
- Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula
- Find the quadratic equation from the given roots
- Boundary Value Analysis : Nature of Roots of a Quadratic equation
- Program to find the Roots of Quadratic equation
- Check if a given number is one less than twice its reverse
- Check if a sequence of path visits any coordinate twice or not
- Find if two given Quadratic equations have common roots or not
- Sub-strings that start and end with one character and have at least one other
- Digital Root (repeated digital sum) of square of an integer using Digital root of the given integer
- Check if Euler Totient Function is same for a given number and twice of that number
- Maximum and Minimum value of a quadratic function
- Sum of first N terms of Quadratic Sequence 3 + 7 + 13 + ...
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Check if product of Array elements in given range are M-th root or not
- Generate all binary strings of length n with sub-string "01" appearing exactly twice

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.