Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given | C ++ implementation of the approach ; 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 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; 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 ; } int main ( ) { double a = 1 , b = 2 , c = 9 , d = 13 , x = 5 ; cout << sum ( a , b , c , d , x ) ; return 0 ; }