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

**Examples:**

Input:A = 2, B = -5, C = 2

Output:Yes

Explanation:

The given quadratic equation is .

Its roots are (1, 1/1) which are reciprocal of each other.

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

Output:No

Explanation:

The given quadratic equation is .

Its roots are (2, 3) which are not reciprocal of each other.

**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 the reciprocal of the other or not by:

- Let the roots of the equation be and .
- The product of the roots of the above equation is given by * .
- It is known that the product of the roots is C/A. Therefore, the required condition is
**C = A**.

Below is the implementation of the above approach:

## C++

`// C++ program to check if roots ` `// of a Quadratic Equation are ` `// reciprocal of each other or not ` ` ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// Function to check if the roots ` `// of a quadratic equation are ` `// reciprocal of each other or not ` `void` `checkSolution(` `int` `a, ` `int` `b, ` `int` `c) ` `{ ` ` ` `if` `(a == c) ` ` ` `cout << ` `"Yes"` `; ` ` ` `else` ` ` `cout << ` `"No"` `; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `a = 2, b = 0, c = 2; ` ` ` ` ` `checkSolution(a, b, c); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to check if roots ` `// of a quadratic equation are ` `// reciprocal of each other or not ` `class` `GFG{ ` ` ` `// Function to check if the roots ` `// of a quadratic equation are ` `// reciprocal of each other or not ` `static` `void` `checkSolution(` `int` `a, ` `int` `b, ` `int` `c) ` `{ ` ` ` `if` `(a == c) ` ` ` `System.out.print(` `"Yes"` `); ` ` ` `else` ` ` `System.out.print(` `"No"` `); ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `a = ` `2` `, b = ` `0` `, c = ` `2` `; ` ` ` ` ` `checkSolution(a, b, c); ` `} ` `} ` ` ` `// This code is contributed by shubham ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to check if roots ` `# of a Quadratic Equation are ` `# reciprocal of each other or not ` ` ` `# Function to check if the roots ` `# of a quadratic equation are ` `# reciprocal of each other or not ` `def` `checkSolution(a, b, c): ` ` ` ` ` `if` `(a ` `=` `=` `c): ` ` ` `print` `(` `"Yes"` `); ` ` ` `else` `: ` ` ` `print` `(` `"No"` `); ` ` ` `# Driver code ` `a ` `=` `2` `; b ` `=` `0` `; c ` `=` `2` `; ` `checkSolution(a, b, c); ` ` ` `# This code is contributed by Code_Mech ` |

*chevron_right*

*filter_none*

## C#

`// C# program to check if roots ` `// of a quadratic equation are ` `// reciprocal of each other or not ` `using` `System; ` `class` `GFG{ ` ` ` `// Function to check if the roots ` `// of a quadratic equation are ` `// reciprocal of each other or not ` `static` `void` `checkSolution(` `int` `a, ` `int` `b, ` `int` `c) ` `{ ` ` ` `if` `(a == c) ` ` ` `Console.WriteLine(` `"Yes"` `); ` ` ` `else` ` ` `Console.WriteLine(` `"No"` `); ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `a = 2, b = 0, 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 numerically equal but opposite in sign or not
- 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 whether one root of the Quadratic Equation is twice of other or not
- Find if two given Quadratic equations have common roots or not
- Program to find number of solutions in Quadratic Equation
- Least root of given quadratic equation for value greater than equal to K
- Absolute difference between sum and product of roots of a quartic equation
- Form the Cubic equation from the given roots
- Find the integral roots of a given Cubic equation
- Maximum and Minimum value of a quadratic function
- Sum of first N terms of Quadratic Sequence 3 + 7 + 13 + ...
- Roots of Unity
- Bakhshali Approximation for computing square roots
- Seeds (Or Seed Roots) of a number
- Find the number of primitive roots modulo prime
- Check if two given circles touch or intersect each other
- Check if two arrays are permutations of each other using Mathematical Operation

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.