Absolute difference between sum and product of roots of a quartic equation | C ++ implementation of above approach ; Function taking coefficient of each term of equation as input ; Finding sum of roots ; Finding product of roots ; Absolute difference ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; double sumProductDifference ( int a , int b , int c , int d , int e ) { double rootSum = ( double ) ( -1 * b ) / a ; double rootProduct = ( double ) e / a ; return abs ( rootSum - rootProduct ) ; } int main ( ) { cout << sumProductDifference ( 8 , 4 , 6 , 4 , 1 ) ; return 0 ; }