text: Find the number which when added to the given ratio a : b , the ratio changes to c : d | C ++ implementation of the approach ; Function to return the required number X ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int getX ( int a , int b , int c , int d ) { int X = ( b * c - a * d ) / ( d - c ) ; return X ; } int main ( ) { int a = 2 , b = 3 , c = 4 , d = 5 ; cout << getX ( a , b , c , d ) ; return 0 ; }