Function to return the sum of numbers which are in the ration a : b and after adding x to both the numbers the new ratio becomes c : d
double sum ( double a , double b , double c , double d , double x ) { double ans = ( x * ( a + b ) * ( c - d ) ) / ( ( a * d ) - ( b * c ) ) ; return ans ; }