- 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
C++ program to find the quantity after mixture replacement
In this tutorial, we will be discussing a program to find the quantity of milk left after mixture replacement.
Let us suppose we have X litres of milk. From that, Y litres of milk is replaced with Y litres of water itself. This same procedure is done again and again Z number of times. Our task is to find the final amount of milk left in the container.
Finding the relation among the values between the repetitive operations, we find the formula for finding the amount of milk after Z number of operations to be
amount left = ((X-Y)/X)Z*X
Example
#include <bits/stdc++.h> using namespace std; //calculating the final amount of milk float calc_milk(int X, int Y, int Z) { float result = 0.0, result1 = 0.0; result1 = ((X - Y) / (float)X); result = pow(result1, Z); result = result * X; return result; } int main() { int X = 13, Y = 2, Z = 5; cout << calc_milk(X, Y, Z) << endl; return 0; }
OUTPUT
5.63884
- Related Articles
- Check for Palindrome after every character replacement Query in C++
- C++ Program for Optimal Page Replacement Algorithm
- C++ Program to find array after removal from maximum
- Program to find the kth character after decrypting a string in C++
- C++ program to find reduced size of the array after removal operations
- Integer Replacement in C++
- C++ program to find maximum possible amount of allowance after playing the game
- Program to find all possible IP address after restoration in C++
- C++ program to find winner of typing game after delay timing
- C++ Program to find room status after checking guest appearance record
- C++ Balanced expression with replacement
- C++ Program to find the Number of Visible Boxes After Putting One Inside Another
- Longest Repeating Character Replacement in C++
- Program to find maximum adjacent absolute value sum after single reversal in C++
- C++ program to find array after removal of left occurrences of duplicate elements

Advertisements