1.

2. WRITE A PROGRAM TO ACCEPT TWO NUMBERS AND DISPLAY THEIR : ► SUMDIFFERENCEMULTIPLICATIONPRODUCT​

Answer»

tion:Find two NUMBERS with sum and product both same as NLast UPDATED: 20-12-2018Given an integer N, the TASK is to find two numbers a and b such that a * b = N and a + b = N. Print “NO” if no such numbers are POSSIBLE.Examples:Input: N = 69Output: a = 67.9851b = 1.01493Input: N = 1Output: NORecommended: Please try your approach on {IDE} first, before moving on to the solution.Approach: If observed carefully, we are GIVEN with sum and product of roots of a quadratic equation.If N2 – 4*N < 0 then only imaginary roots are possible for the equation, hence “NO” will be the answer. Else a and b will be:a = ( N + sqrt( N2 – 4*N ) ) / 2b = ( N – sqrt( N2 – 4*N ) ) / 2



Discussion

No Comment Found