- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d) in C++

In this tutorial, we are going to write a program that calculates ∆ X value that satisfies the given equation. The equation is (a + ∆ X)/(b + ∆ X) = c/d.

Here, we need a little bit of math to solve the equation. And it's straightforward. Cross multiply and take ∆X to one side.

You will get the value of ∆X as (b*c-a*d)/(d-c).

We are given a, b, c, and d values. Finding \Delta XΔX value is straightforward.

## Example

Let's see the code.

#include <bits/stdc++.h> using namespace std; int findTheXValue(int a, int b, int c, int d) { return (b * c - a * d) / (d - c); } int main() { int a = 5, b = 2, c = 8, d = 7; cout << findTheXValue(a, b, c, d) << endl; return 0; }

## Output

If you run the above code, then you will get the following result.

19

## Conclusion

If you have any queries in the tutorial, mention them in the comment section.

- Related Questions & Answers
- C++ program to find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d)
- C program to convert decimal fraction to binary fraction
- Converting a proper fraction to mixed fraction - JavaScript
- Convert decimal fraction to binary number in C++
- Fraction to Recurring Decimal in C++
- Find the multiple of x which is closest to a^b in C++
- C program to represent numbers in numerator and denominator in string format
- Fraction module in Python
- Reduce the fraction to its lowest form in C++
- How to display fraction in base R plot?
- K-th Smallest Prime Fraction in C++
- Find multiple of x closest to or a ^ b (a raised to power b) in C++
- Find four elements a, b, c and d in an array such that a+b = c+d in C++
- Program to find common fraction between min and max using given constraint in Python
- Find all pairs (a,b) and (c,d) in array which satisfy ab = cd in C++

Advertisements