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.
Live Demo
#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 Articles
- 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)
- A fraction becomes $\frac{9}{11}$ if 2 is added to both numerator and the denominator. If 3 is added to both the numerator and the denominator, it becomes $\frac{5}{6}$. Find the fraction.
- A fraction becomes $\frac{1}{3}$ if 1 is subtracted from both its numerator and denominator. If 1 is added to both the numerator and denominator, it becomes $\frac{1}{2}$. Find the fraction.
- The numerator of a fraction is 3 less than the denominator. If 2 is added to both the numerator and the denominator, then the sum of the new fraction and the original fraction is $\frac{29}{20}$. Find the original fraction.
- Find the equivalent fraction of \( \frac{3}{5} \) having(a) denominator 20 (b) numerator 9(c) denominator 30 (d) numerator 27
- Find the equivalent fraction of \( \frac{13}{7} \) havinga. numerator 52 .b. denominator 49.c. numerator 130.d. denominator 63.
- The denominator of a fraction is 4 more than twice its numerator. Denominator becomes 12 times the numerator. If both the numerator and the denominator are reduced by 6. Find the fraction.
- When 3 is added to the denominator and 2 is subtracted from the numerator a fraction becomes $\frac{1}{4}$. And, when 6 is added to numerator and the denominator is multiplied by 3, it becomes $\frac{2}{3}$. Find the fraction.
- In a fraction, twice the numerator is 2 more than the denominator. If 3 is added to the numerator and denominator the new fraction is $\frac{2}{3}$. Find the original fractions.
- The numerator of a fraction is 6 less than the denominator. If 3 is added to the numerator, the fraction is equal to $\frac{2}{3}$. What is the original fraction equal to?
- The sum of a numerator and denominator of a fraction is 18. If the denominator is increased by 2, the fraction reduces to $\frac{1}{3}$. Find the fraction.
- If 2 is added to the numerator of a fraction, it reduces to $\frac{1}{2}$ and if 1 is subtracted from the denominator, it 1 reduces to $\frac{1}{3}$. Find the fraction.
- The denominator of a fraction is 7 more than its numerator. If '1' is subtracted from both the numerator and the denominator, it becomes $\frac{9}{6}$. Form an equation to find the value of the actual fraction.
- The sum of numerator and denominator of a fraction is 3 less than twice the denominator. If each of the numerator and denominator is decreased by 1, the fraction becomes $\displaystyle \frac{1}{2}$, find the fraction.
- The sum of the numerator and denominator of a fraction is 12. If the denominator is increased by 3, the fraction becomes $\frac{1}{2}$. Find the fraction.
Kickstart Your Career
Get certified by completing the course
Get Started