Saturday, 16 Oct 2021

# Quadratic equation whose roots are K times the roots of given equation

Quadratic equation whose roots are K times the roots of given equationGiven three integers A, B, and C representing the coefficients of a quadratic equation Ax2 + Bx + C = 0 and a positive integer K, the task is to find the coefficients of the quadratic equation whose roots are K times the roots of the given equation.Examples:Input: A = 1, B = 2, C = 1, K = 2Output: 1 4 4Explanation:The given quadratic equation x2 + 2x + 1 = 0.Roots of the above equation are -1, -1.Double of these roots are -2, -2.Therefore, the quadratic equation with the roots (-2, -2) is x2 + 4x + 4 = 0.Input: A = 1, B = -7, C = 12, K = 2Output: 1 -14 48Approach: The given problem can be solved by using the concept of quadratic roots. Follow the steps below to solve the problem:Let the roots of the equation Ax2 + Bx + C = 0 be P and Q respectively.Then, the product of the roots of the above equation is given by P * Q = C / A and the sum of the roots of the above equation is given by P + Q = -B / A.Therefore, the product of the roots of the required equation is equal to:  (K * P ) * (K * Q) = K2 * P * Q = (K2 * C ) / ASimilarly, the sum of the roots of the required equation is 2 * K (-B / C).Therefore, the required quadratic equation is equal to: x2 – (Sum of the roots)x + (Product of the roots) = 0=> Ax2 + (KB)x + (K2)C = 0Below is the implementation of the above approach:C++#include using namespace std;  void findEquation(int A, int B, int C,                  int K){        cout