

- 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 amount of water wasted after filling the tank in C++
In this tutorial, we are going to solve the following problem.
Given a tank with a capacity of N liters and a pump that fill the tank with S speed per minute. Unfortunately, there is a hole in the tank. And water is wasting at a speed of WS per minute while filling it.
We need to calculate the amount of water wasted for a full tank.
The amount of water filled per minute is equal to the difference between the water filling water and wasting water speed.
Hence we can get the total time to fill the water tank by dividing the capacity of the water tank by the filling speed per minute.
And we can easily get the wastage of water by multiplying the wasting water speed with the time to fill the water tank.
Example
Let's see the code.
#include <iostream> using namespace std; double countTheWastedWater(double N, double S, double WS) { double wasted_water, fill_per_minute, time_to_fill; fill_per_minute = S - WS; time_to_fill = N / fill_per_minute; wasted_water = WS * time_to_fill; return wasted_water; } int main() { double N, S, WS; N = 275; S = 10; WS = 3; cout << countTheWastedWater(N, S, WS) << endl; return 0; }
Output
If you execute the above program, then you will get the following result.
117.5
Conclusion
If you have any queries in the tutorial, mention them in the comment section.
- Related Questions & Answers
- Program to check if water tank overflows when n solid balls are dipped in the water tank in C++
- C++ program to find maximum possible amount of allowance after playing the game
- Program to find the formatted amount of cents of given amount in Python
- Finding number of open water taps after n chances using JavaScript
- Find a specified amount of records in MongoDB?
- Program to find largest island after changing one water cell to land cell in Python
- How to redirect website after certain amount of time without JavaScript?
- How to reduce MongoDB storage space after deleting large amount of data?
- C++ code to find out the total amount of sales we made
- Types of Electric Water Heater (Plate Heater, Immersion Water Heater, Geyser)
- Display the maximum amount of memory in Java
- Find out the minimum number of coins required to pay total amount in C++
- Program to Find Out the Amount of Rain to be Caught between the Valleys in C++
- Return the common filling value of two masked arrays in Numpy
- C program to find amount of volume passed through a tunnel