- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 amount to be added to achieve target ratio in a given mixture in C++
Suppose we have a container with size X. It has a mixture of water and other liquid, the mixture has W% of water in it. We have to find how many water must be added to increase the ratio of water to Y%? If X = 125, W = 20 and Y = 25, then output will be 8.33 liters.
Suppose we have to add A amount of water with the previous mixture, so new amount will be X + A. So the amount of water in the mixture will follow this formula.
Old Amount+A=((W% of X) + A)
Also the amount of water in the mixture = new percentage of water in the new mixture. So this is Y% of (X + A).
So we can express it like − Y% of (X + A) = (W % of X) + A
A = [X * (Y - W)] / [100 - Y]
Example
#include<iostream> using namespace std; float getWaterAmount(float X, float W, float Y) { return (X * (Y - W)) / (100 - Y); } int main() { float X = 125, W = 20, Y = 25; cout << "We need "<< getWaterAmount(X, W, Y) << " liters of water"; }
Output
We need 8.33333 liters of water
- Related Articles
- Program to find the formatted amount of cents of given amount in Python
- Program to find a target value inside given matrix or not in Python
- Print elements that can be added to form a given sum
- Program to find number of ways to form a target string given a dictionary in Python
- Program to find number of given operations required to reach Target in Python
- Program to Find Out the Amount of Rain to be Caught between the Valleys in C++
- Find the minimum value to be added so that array becomes balanced in C++
- How to find the unique triplet that is close to the given target using C#?
- Find minimum number of currency notes and values that sum to given amount in C++
- Program to find lowest sum of pairs greater than given target in Python
- Program to find number of sublists whose sum is given target in python
- How to find the target sum from the given array by backtracking using C#?
- Program to find final amount that should be paid to employees based on their performance in C++
- What should be added to each term of the ratio 7:13 so that their ratio becomes 2:3?
- What number must be added to each term of the ratio 7 : 12, so that the ratio becomes 4 : 5?

Advertisements