Dev C++ Programming

Can anyone help me solve this problem?.I think you would use loop but I don't know to put it in as a code.
Write a program that, given the initial shampoo volume, will keep track of the
shampoo concentration after each use until the bottle is empty.
formula:
C new= C old(V-5)/V+5
sample:
On 1st use, she uses 5 ml of 100% shampoo and adds 5-ml water to get
50 ml at 90% concentration (shampoo volume reduced to 50 ml –
5 ml×100% = 45 ml).
output
enter 50
1 Concentration: 90.00% Volume: 50 ml
2 Concentration: 81.00% Volume: 50 ml
3 Concentration: 72.90% Volume: 50 ml
4 Concentration: 65.61% Volume: 50 ml
5 Concentration: 59.05% Volume: 50 ml
6 Concentration: 53.14% Volume: 50 ml
7 Concentration: 47.83% Volume: 50 ml
8 Concentration: 47.83% Volume: 45 ml
9 Concentration: 47.83% Volume: 40 ml
Hi,

there is a confusion regarding the question. If each time she uses 5 ml of content from the bottle, and then fill 5 ml of water as a compensation, then how come the volume of bottle reduced to 45 ml on step 8 and 9 ?
I think you have the formula wrong. Shouldn't it be C(new) = C(old)*(V-5)/V? If the concentration is C and you use 5ml then amount of shampoo remaining in the container is C(V-5). If you then replace the 5ml with water then the new concentration is C(V-5)/V.

You can code this inside a loop. The question then becomes "when does the loop stop?" That will tell you whether it's better to use a for loop or while loop.
Topic archived. No new replies allowed.